none
WCF RAI Services works on local IIS, but gives NotFound error when deployed

    Question

  • Hi,

    This pehenomeon drives me crazy.

    I cretated a LOB appl that uses WCF RIA Services  and works well on dev enviroment and on the local IIS on the dev machine (IIS 7), but give a 404 NotFound error on the hoster's server. I can't navigate to services via urls.

    I read all the proposed literature from similar threads, the web.config is tripple checked.

    I created a test application, that uses the production database, that installed on the hoster. The test appl able to return items from database table.

    Then I created custom membership, role and profile providers in the test appl with the same code, as in the production appl, and I can navigate to these services via url, but I can't navigate to the similar services in the production appl.

    Then I put the test's appl. web.config into the production appl root folder, and it didn't work, but works in the dev enviroment (after changed the connstring).

    It seems, the web.config is ok, the hoster's server infrastructure is ok (the test application is working) and the connstring is ok too, because the test appl riches the same database, that the production should.

    Does anybody has any idea to give me some proposals, how to investigate this issue, because I'm now out of any idea.

    Thanks in advance

    Gabor

    Monday, October 10, 2011 7:40 AM

Answers

  • You can take a look on this blog to check what you are missing:

    http://sladapter.blogspot.com/

    Monday, October 10, 2011 4:53 PM
  • Then I really have no idea.  Compare both web.config files to see if anything is different.

    By the way, could you check if you have a "PrecompliedApp.config" in your real app folder? If you see this file, delete it before try your app. I remember there was a similar problem talked in this thread and we finally find it was "PrecompiledApp.config" file caused problem:

    http://social.msdn.microsoft.com/Forums/en-US/silverlightwcf/thread/a81856ce-960a-4fb6-81ae-1a5428b49226//1/10

    If nothing works, you could try to use your Test web project as your real project. Move the files (or just copy code) from the old web project over to this Test project. Be sure to test on each step.  You can leave the Silverlight project mostly unchanged. Just change the RIA link to point to the new Web project.  In the new Web project, add Silverlight link to point to your Silverlight project.

    Thursday, October 13, 2011 10:33 AM
  • The problem solved.

    My LOB appl uses a third party printing component wich installed on the local machine's GAC, so everything worked on my machine, but didn't worked on the server, because I forgot to set the needed assambly as copy local Embarassed

    What misled me, is the fact, that missing of these DLLs precluded the runtime creation of all of the WVF RIA Services. The printing functionality uses WCF, not the WCF RIA Services.

    My test application had been working, until I included the printing service.

    Thanks for everybody who helped me to solve the problem, I gave so many idea, that will help me to investigate similar issues in the future.

    Thanks again

    Gabor

    Wednesday, October 19, 2011 8:32 PM

All replies

  • try the below things to check the website

    1. Just add a plain html page to the same url and try to navigate whether u can access html page. If it works then problem with the aspx handler.

    2. If the above works. Add a plain aspx page and try navigate to it.

    3. Make sure the XAP file HTTPhandler is added to the IIS server in the production.

    4. Is it https or http in the production? if https make sure port 445 is open

    Monday, October 10, 2011 12:41 PM
  • Is the client config in your xap still referencing "localhost"?

    Monday, October 10, 2011 3:22 PM
  • Thanks for the answer.

    1. I can navigate to the html page, because the not working appl is in the html page, and the appl shows up, I can't to invoke methods, moreover the test appl works fully if I change the production appl to the test.

    2. Both appls use the http

    Thanks,

     

    Gabor

    Monday, October 10, 2011 4:46 PM
  • You can take a look on this blog to check what you are missing:

    http://sladapter.blogspot.com/

    Monday, October 10, 2011 4:53 PM
  • Is the client config in your xap still referencing "localhost"?

    Sorry but look where? Nor in the real, neither in the test appl I don't see the client.config file in the xap. I'm using WCF RA Services, maybe the system set everything as needed?

    The test appl works fine.

    Thanks

    Monday, October 10, 2011 5:09 PM
  • You can take a look on this blog to check what you are missing:

    http://sladapter.blogspot.com/

    Thanks Sully, I followed the instructions in this blog, when I deployed the app to the localhost, and the real appl is working in local IIS, but not working on the hoster.

    The test appl works in the hoster. Both appl use the same database, use the same connection string, and has methods with common code inside.

    For that porpose I expect, the web.config, the connection strings and the server's infrastructures are set appropriately.

    Because I can't get any detailed error with Fiddler but 404 Not Found, I'm not sure, does the real appl's DomainServices are created at all? How to determine this?

    Thankss ina advance

    Gabor

    Monday, October 10, 2011 5:20 PM
  • What is this hoster? What is the difference between this hoster and your local IIS?

    Have you tested your Service first by typing your service URL in a browser (find the service URL in your RIA Generated code *.g.cs)? Do you get the correct service response or an error page?

    Monday, October 10, 2011 5:30 PM
  • Thanks Sally,

    The hoster is a service provider that gives us a shared hosting, and I can't investigate the server's settings.

    I can navigate to the test appl's services URI, but the real appl. responds with 404 NotFound error page, and the Fiddler doesn't give any more detailed information.

    Monday, October 10, 2011 5:56 PM
  • "404 NotFound" error could mean anything in this case. Usually it is not a service connection issue, but an error occurred in your service code.

    Several things you can try:

    1) Set serviceDebug includeExceptionDetailInFaults="true" in the following service behavior:

     <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>

        ..

     </system.serviceModel> 

    2) Do you have trace turned on? If not, try to turn on the trace so you can inspect the trace file.

    3) Override OnError function in your Authentication Service and other Domain Service. You can write the error to a log so you can inspect it later.

     protected override void OnError(DomainServiceErrorInfo errorInfo)
            {
                base.OnError(errorInfo);

                //Add your log code
             }

    Monday, October 10, 2011 7:16 PM
  • Thanks Sally.

    1. I modified the web.config, as You proposed, but I didn't get more detailed error info in the Fiddler but 404 NotFound.

    2. Do You mean the WCF RIA Services trace?

     

    Monday, October 10, 2011 8:33 PM
  • Yes, you can turn on Service trace in the web.config. Check this thread on how to do that:

    http://social.msdn.microsoft.com/Forums/en-US/silverlightwcf/thread/a81856ce-960a-4fb6-81ae-1a5428b49226//1/10

    Monday, October 10, 2011 8:48 PM
  • I don't use Ria Services so maybe it doesn't require a client config.  To see what your .xap contains, rename it to .zip.  Then open it up and look for the files.  Make changes to the client config (if any) and then rename the zip back to xap.

    If it doesn't contain a client config file, then that isn't the issue.

    Tuesday, October 11, 2011 9:26 AM
  • Ria Service doesn't have a client config file.

    Tuesday, October 11, 2011 9:31 AM
  • Hi Sally

    I turned on the service trace, as You proposed.

    Now my VS2010 uses the local IIS, and everything work well in VS2010 and from localhost too.

    On production server (at the hoster), I get the 404 NotFound error. Fiddler doesn't show anything more. The log file is empty, seems, tho DomainService doesn't exist at all on the hoster's server.

    What the cause could be?

    Thanks in advance

     

    Tuesday, October 11, 2011 7:50 PM
  • Does anybody can me point to the right direction, how to invesigate the NotFound error, when the DomainServices obviously don't exist on the production server, but works well on the local IIS wich is on the developer's PC.

    Th svclog is empty, and the rewroted service's OnError doesn't claim any error.

    Why the WCF RIA Services doesn't create the DomainServices at runtime?

    Any idea will be greatly appreciated.

    Gabor

    Wednesday, October 12, 2011 6:26 AM
  • Have you tried to see if the service works outside your app?  Try just making the browser url be <yoururl>/service.svc (or whatever your svc name is).  Does that give you an error?  If it doesn't, then the problem might be actually inside your service.  Perhaps you don't have database permissions.

    I make a service behavior that allows me to pass back to the client all exceptions on the service.  If the service itself is working, then sometimes the error message can be displayed on the client through that service behavior.  Here is one place that talks about doing this:

    http://www.codeproject.com/KB/silverlight/silverlight_exception.aspx

    Wednesday, October 12, 2011 9:01 AM
  • Thanks,

    Unfortunately I can't access the services via direct URI, get the NotFound error.

    The services don't constructed at all on the production server, because the trace file is empty.

    Thanks for the link, I will look into.

    Wednesday, October 12, 2011 9:25 AM
  • Unfortunately I can't access the services via direct URI, get the NotFound error.

    I asked you to do this in my first post and this was what you said:

    "I can navigate to the test appl's services URI, but the real appl. responds with 404 NotFound error page, and the Fiddler doesn't give any more detailed information."

    So I thought you could access the service, just not from the Silverlight app.

    If you could not access the service using service URL, check if the server has RIA service installed.

    Wednesday, October 12, 2011 9:31 AM
  • http://www.codeproject.com/KB/silverlight/silverlight_exception.aspx

    This is a very nice article, but in my case, I get the 404 NotFound and not the 500 error, and the services don't exist at all on production server, but works without any error on loca IIS.

    Thanks

    Wednesday, October 12, 2011 9:35 AM
  • Thanks Sally

    "I can navigate to the test appl's services URI, but the real appl. responds with 404 NotFound error page, and the Fiddler doesn't give any more detailed information."

    So I thought you could access the service, just not from the Silverlight app.

    If you could not access the service using service URL, check if the server has RIA service installed.

    I apologize because of the ambiguous information, so I have to clarify:

    I have two different SL4 applications created from navigation template installed on the production server. Both of them uses the same database.

    The test application works fine, and get records from the db tables via WCF RIA Services.

    The real application wich has a WCF RIA Service method equivalent to test appl's method, doesn't work, send a 404 NotFound Error. The log file is empty, and I can't access the service via url. The Fiddler doesn't give any more information. It seems, that in the real application the DomainServices don't created runtime at all. Why?

    Both appls works fine on the local IIS on the dev machine.

    On the server the infrastructure installed well, because the test application works.

    So I can't imagine, how to open up the cause of this error.

    Thanks in advance

    Gabor

    Wednesday, October 12, 2011 1:36 PM
  • It still isn't clear to me if you got the service.svc to work from a uri.  Does that much work?  If not then you have some very basic thing wrong.  If it does work, then the problem is probably within the service implementation code.  And it could likely be something like the User under which the service is running doesn't have rights to the database.

    So does the service.svc give you browser output?  Or an error message?   (yours might not be called service.svc, but it is likely something .svc)

    Wednesday, October 12, 2011 1:46 PM
  • I have two different SL4 applications created from navigation template installed on the production server. Both of them uses the same database.

    The test application works fine, and get records from the db tables via WCF RIA Services.

    What is the difference between this Test application and the real one since both uses WCF RIA service and even the same DB?

    Wednesday, October 12, 2011 1:59 PM
  • What is the difference between this Test application and the real one since both uses WCF RIA service and even the same DB?

    The real appl is a full featured business appl wich uses navigation framework and fragment navigation. In that appl I rewrote the asp.net membership-, profile- and role providers. Every service method requires authentication but the registration and forgot password respectively and it doesn't work. When I navigate to the uri, the browser shows the appl's basic pages with the menu system. These pages don't use any service. When the user clicks login, or demo, the appl go to other pages (fragment navigation). These pages use the services. In reality I can't navigate to these pages, because the unsuccesfull login.

    To test the infrastructure installed on the hoster's server, I created another SL4 appl. with the built in Business template, but removed all the plumbing (built in pages and authentication service). Created a very basic MainPage with a datagrid control and two buttons. On the test.web I added two WCF RIA Service classes. One of them return only a string, and another returns all records from one of the tables, that is in the production database. The database is on another server machine, and the hoster's administrator set the connection string to that SQL Server 8 Database. So the two programs the test and real use the same database.

    This test application works as expected.

    To open up the disfunctionality of the real application, I created these same services. I created a new child window, with two buttons and created the same services (one get a string, another get records from the same datbase's table). These services don't require authentication. These services don'twork, and I can't access them via uri.

    Because I thaught, maybe the providers cause the problems, I created the same providers in the test appl. Nothing changed, the test appl. works.

    At the hoster I have a virtual directory, and in this directory I change the real or test appl for investigation.

    Both application works in dev machine. In dev machine (Vista) the real program uses the built in IIS. It works from VS2010 and from localhost too. 

    What to try next? I'm realy frustrated.

    Gabor

    Wednesday, October 12, 2011 6:48 PM
  • Looks like your Testing app doesn't use authentication service which is the real problem in your real app.

    Why don't you create a simple test project using Business Application template. You should not have to write any code or change any code. This way you can test the authentication service.

    At the hoster I have a virtual directory, and in this directory I change the real or test appl for investigation.

    Did you just create a virutal directory, not an application? If that is the case, you need to turn that virtual directory into a Web application. 

    Wednesday, October 12, 2011 8:15 PM
  • Looks like your Testing app doesn't use authentication service which is the real problem in your real app.

    The test appl doesn't use the Authentication service, but is there. The real appl uses the authentication service, but I have test services, that don't require authentication, despite this they don't work too. Maybe only the presence of the authentication service preclude the normal working of other services, even if they don't use them?

    Did you just create a virutal directory, not an application? If that is the case, you need to turn that virtual directory into a Web application.

    I published my real application to the local file system, as I read in your blog post http://sladapter.blogspot.com/ 4-7 and uploaded the created directory's content to the hoster's administrator, who put them into the appropriate place. (Created a virtual directory and set the IIS accordingly). For the real appl this doesn't work. Then I did the same steps for the test application. I deleted all the files from the MySite.wwwroot directory and upload the local setup's folder content and this works.

    From that time I change that directory's content, when I switch betwween the real and test appl.

    What did I wrong?

    Thanks

    Gabor

    Wednesday, October 12, 2011 9:06 PM
  • The test appl doesn't use the Authentication service, but is there.

    Did you try to do login on your test app to test the authentication service? Just want to see if the authentication service (also a RIA service) under your test app works.

    The real appl uses the authentication service, but I have test services, that don't require authentication, despite this they don't work too. Maybe only the presence of the authentication service preclude the normal working of other services, even if they don't use them?

    Unless your service need authentication. Otherwise, I don't see how different this service running under your real app and the test app.

    You can access the service using the service URL when the service is under the test project, but you can't access it when the same service under the real app?  Then I have no idea without seeing the real code and setup.

     

    Wednesday, October 12, 2011 9:35 PM
  • You can access the service using the service URL when the service is under the test project, but you can't access it when the same service under the real app?  Then I have no idea without seeing the real code and setup.

    The appls differ, but the authentication, role and profile provider's code are the same. Also the myService.svc code, that returns a string, and the ItemService.svc code that return records from the same production dtabase are same too.

    I will try the Authentication service in the test appl now. Thanks for the idea.

    Thursday, October 13, 2011 12:14 AM
  • When you use Service URL to test, you are only testing the connection, not functions. So it doesn't matter what function is used in your Silverlight app or what kind of data is returned because you don't even hit any of those code yet. 

    That's what puzzles me.  You said the real app works fine under local IIS (I don't mean under VS), right? So it doesn't look like a web.config issue either.

    Thursday, October 13, 2011 9:37 AM
  • You said the real app works fine under local IIS (I don't mean under VS), right? So it doesn't look like a web.config issue either.

    The application works under local IIS, I can access the service as http://localhost/MyApp.Web/ClientBin/MyApp-Web-Services-ItemService.svc in the browser.

    I modified the test application to use the authentication service (with the same code that I'm using in the real appl), and this works too.

     

    Thursday, October 13, 2011 10:27 AM
  • Then I really have no idea.  Compare both web.config files to see if anything is different.

    By the way, could you check if you have a "PrecompliedApp.config" in your real app folder? If you see this file, delete it before try your app. I remember there was a similar problem talked in this thread and we finally find it was "PrecompiledApp.config" file caused problem:

    http://social.msdn.microsoft.com/Forums/en-US/silverlightwcf/thread/a81856ce-960a-4fb6-81ae-1a5428b49226//1/10

    If nothing works, you could try to use your Test web project as your real project. Move the files (or just copy code) from the old web project over to this Test project. Be sure to test on each step.  You can leave the Silverlight project mostly unchanged. Just change the RIA link to point to the new Web project.  In the new Web project, add Silverlight link to point to your Silverlight project.

    Thursday, October 13, 2011 10:33 AM
  • Compare both web.config files to see if anything is different.

    The web.configs differs because of the thirdparty printing component that uses its own db tables and own WCF (not WCF RIA) services. But I tried to use the test appl web.config with the real program (without the printing part), and it worked in local IIS but not at the hoster.

    By the way, could you check if you have a "PrecompliedApp.config" in your real app folder

    This file isn't in the app folder.

    you could try to use your Test web project as your real project. Move the files (or just copy code) from the old web project over to this Test project

    Thank You for the idea, I'm doing this now.

    We created a new Web for the test application to see does it work on the new place too.

    At the momnet I can't establish, where is the problem. In the appl? In that case why it is working on local IIS, or the hoster's IIS settings are wrong, but then why the test appl works in the same folder, where the real appl doesn't.

    Thursday, October 13, 2011 8:32 PM
  • Just change the RIA link to point to the new Web project.  In the new Web project, add Silverlight link to point to your Silverlight project.

    Could You please clarify, how to do that?

     In the real project I can't change the link to point to the test.web project, and how to add Silverlight link to pint to my real appl Silverlight project?

    Thanks

    Gabor

    Friday, October 14, 2011 8:26 PM
  • Open your Silverlight project Property page (right click the project then select Property context menu), you should see "WCF RIA Service link" select box on that Page. You can select your Test Web Project.  After you done this make sure to compile both projects (Silverlight and Web project).

    Open your Test Web project Property page, on the Silverlight Application Tab you should see Add Silverlight link box. Add Silverlight link to point to your Silverlight project.

    Saturday, October 15, 2011 8:14 AM
  • The problem solved.

    My LOB appl uses a third party printing component wich installed on the local machine's GAC, so everything worked on my machine, but didn't worked on the server, because I forgot to set the needed assambly as copy local Embarassed

    What misled me, is the fact, that missing of these DLLs precluded the runtime creation of all of the WVF RIA Services. The printing functionality uses WCF, not the WCF RIA Services.

    My test application had been working, until I included the printing service.

    Thanks for everybody who helped me to solve the problem, I gave so many idea, that will help me to investigate similar issues in the future.

    Thanks again

    Gabor

    Wednesday, October 19, 2011 8:32 PM