Unable to consume WCF service (hosted in IIS ) - asp.net

I have hosted my web-application in IIS 5 in a virtual directory.
When browsing .aspx web pages everything works fine. Web-page takes few inputs from user and invokes WCF services. On making the service call I get below exception -
There was an error in serializing body of message : 'Unable to
generate a temporary class (result=1). error CS2001: Source file
'C:\WINDOWS\TEMP\peqft5u5.0.cs' could not be found error CS2008: No
inputs specified '
I have double checked environment variables looks good in the server.
I can confirm, there is no problem in code since, same works perfectly fine in other box of similar configuration & hosting environment.

ASP.NET default user was not having write access to TEMP folder. Posting the answer in hope it would be helpful later, some day!

Related

Server error when copying ASP.NET code to another host

Sorry for the simple question.
I have moved a site to a host by simply copying the code but even the first login page fails if I include the following :-
In Web.config file..if I add the following
or...
Aspx page..if I include a reference to a class file ( which does exist in the app_code directory )
Sign In <%If clsGeneral.str(Request("timeout")) = "t" Then Response.Write(" - YOUR SESSION EXPIRED")%>
I get the error...
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
etc...
Copying an application from one host to another is only simple in the file copy. There are a number of issues that may arise from the application running on the "new" server. For example, is the server running the same version of IIS? Is IIS configured properly for this application? Etc ... to see what error the application is throwing, inspect the Application Log in the event viewer on the server. This will give you some hint as to what the issue is. Without that information, there's really no place you can start, except maybe turning off the custom error or error suppression to see the error details in the browser. But I would recommend that you inspect the Application event log on the server.

Hosting WebAPI as application inside WebForms in IIS gives 500 error

I have a Webforms application which is hosted in IIS on my local machine. This works fine and there are no issues with this site itself.
I have now created a WebAPI that I want to sit on the same domain as a ‘folder’ within the web forms application, so I have added a new application within the WebForms site in IIS and pointed it to this WebAPI. The API, in standalone mode (i.e. running direct from VS) works fine, but when I try to access it via the Webforms site (e.g. www.webformssite.com/iis-applciation-name/api/test) I get a generic 500 Internal server error response and absolutely no detail. If I hit the API directly within IIS (as a separate site) it also works fine so its only when accessing it as an IIS application.
I've tried using a new app pool for the WebAPI application and re-using an existing one but it makes no difference.
I’ve read lots of SO questions about the same issue (i.e. 500 error returned from WebAPI) but nothing has helped. I’ve followed this (http://www.asp.net/web-api/overview/testing-and-debugging/exception-handling) guide too and implemented a global exception filter, put a breakpoint on that and again nothing gets hit. Also, the global error handler in the parent webforms site never fires either so I dont think that is somehow erroring...
I’m not 100% sure if it’s the parent Webforms site, the WebAPI or my IIS config that’s at fault here. The WebForms and WebAPI are both asp.net 4.0 sites in IIS if that is relevant.
Edit:
I have turned on Failed Request tracing and the only relevant part I can see is:
-MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName
AspNetInitializationExceptionModule
Notification
BEGIN_REQUEST
HttpStatus
500
HttpReason
Internal Server Error
HttpSubStatus
0
ErrorCode
The operation completed successfully.
(0x0)
ConfigExceptionInfo
Nothing else in the failed request trace seems to have any hint of a problem/error!?!
Any hints/suggestions much appreciated.

ASP.NET WEB API 2 Works Locally But Not On Production Web Server

I've developed a new WEB API 2 that works great locally, however when I upload the same code to my production server (Arvixe in this case) all I get is a 404 when I call it. I've spent HOURS searching the web, reading forums, etc.. and have been able to find no resolution, so I'm asking here as my last effort.
I'm currently only testing with the default project that gets created when you do New Project > ASP.NET Web API 2 Empty Project in Visual Studio. This creates an empty project with a single ValuesController. You should be able the JSON response by called /api/values, but this doesn't even work.
I'm using Fiddler to test the API locally and on the web server.
http://localhost:1993/api/values <--- works great
but
http://api.mydomain.com/api/values <--- returns 404
Note: I created a subdomain "api" in this case, but everything for the code for the API is unchanged from when it was created.
Why in the world does this work locally but not on the production web server?
That the server returns 404 (Not Found) may indicate a lot of things. However you can check using the following step:
Add a simple text document like readme.txt to your a folder sub-domain http://api.mydomain.com, and try to get access to that. If you can't access to that file, it means that the subdomain is not configured properly.
Publish the webservice using the "Publish" functionality, so that all DLLs will be copied.
After that,try to reach the Web ApI again.
Hope that help.
"Note: I created a subdomain 'api' in this case, but everything for the code for the API is unchanged from when it was created."
Above comment of your's is suspicious, you should publish your WEB API application in the root directory. Like if http://example.com is pointing to "MyExample" folder, then application should be published on "MyExample" folder.
After that you will be able access your api with http://example.com/api/{controller}/{action}
Just a simple suggestion which I'm sure you have already considered, but have you opened the http port 80 on the server's firewall?
Also stick a plain old html file in the root of your project and see if the server serves it up.
in your case, since you create a subdomain of 'api', you should try
http://api.mydomain.com/api/api/values
note that if you're using database for the function, you should change the connectionString in your web config
Please verify the .net framework on you hosted domain that may be old one.
Web api 2 is supposed on 4.5 framework.
One reason for web api 2 method working OK on local machine but not on production server is that the method you are calling is working on local machine but not on remote server. In such a case you will receive message 404 or 500, and you would be lost why this routing is failing.
Why a method would fail on remote server, well there may be many reasons. For me, I was querying database in my method and my connectionString was not set for remote server.
One way of resolving it would be to put some very simple code in that particular method and test that routing is working. Then check your original code for errors reasons.

Changing "Project Url" causes ASP.Net Web app to not be debuggable

I have an ASP.NET Web Application project that I am using to host a WCF Data Services (OData) project.
I went and changed the url from:
http://localhost/MyProject
to
http://localhost/v1/MyProject
after I did that I created a Virtual Directory for the new project URL.
Now when I run I get this error:
Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information.
I clicked help but it was no help (was IIS 6 level instructions, I have IIS 7). I did some googling and it was all fairly generic responses.
How can I get this working again? (Aside from revert to my old Url. Reverting works but I changed it for a very good reason.)
Your virtual directory need to point to the same scr directory you were originally debugging against.
Also, make sure the virtual directory is configured for Windows Authentication, which is required for debugging.
I had to go to my website in IIS and add a folder under it called v1. After I did that it all worked perfectly.

ASP.NET: Errors not viewable despite proper configuration

I'm having the classic (dare I say typical?) error on the ASP.NET production server, which tells me that I can't view errors. Below the error displayed below, are things I've already tried.
In IIS Manager (6.0), the application is located under one of the web sites in "Web Sites". It is indeed a web application, as opposed to a virtual directory (it has that gear icon).
When trying to view the error from the localhost (i.e. the server itself), it doesn't find the application on its path, even though the root web site works just fine from localhost. It is clearly not a firewall issue because first of all, the firewall is turned off, and second because the root web site works fine from localhost. Heck, I even tried connecting through telnet and that worked fine and dandy too, so it is most certainly and very clearly not a firewall issue.
Basically, I just need to view the error at all. I won't have to fix this problem if I can just see the error and fix it, because obviously there is something wrong in the code itself... I just don't know what, because IIS/.NET won't tell me.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
So what I've already tried is what the error message itself suggests by setting the customErrors thing to "Off". In fact, it always was on "Off" so I didn't have to change anything. I've made sure that the web.config XML is valid.
Another common reason for this error is that the .NET run-time is set to version 1.1, not 2.0. I've also made sure that this is correctly configured to 2.0.
I'm running it in an independent application pool, meaning that there are no other applications at all, much less 1.1 applications, on the same application pool.
I've made sure that EVERYONE can do ANYTHING to the files and directories in the application itself. I understand the security ramifications here, I'm just trying to get it working at all, and then I'll constrain the access rights afterward, one step at a time. But in any case, everyone can read those files.
Any help deeply appreciated. Thank you in advance.
The error is a .NET framework error so it finds the app, but there is a configuration error. What you could do is add some event logging code in APplication_Error handler in global.asax to trap these errors, or turn on health monitoring (<healthMonitoring enabled="true" />), which by default will log ASP.NET framework errors to the event log.
HTH.
Never got this working until I changed the application from a "sub-application" (I don't know the proper terminology) to an independent website with its own hostname. ASP.NET works in mysterious ways.

Resources