Nandini
Nandini

Reputation: 393

Error When running asp.net Application in IIS

I have an application in asp.net.I configured it in IIS.When i running this application in IIS i getting an error;

Server "/" error:
Resource Cannot be Found
Error:404

Some of pages only produce this issues.Other forms are working perfectly.Without running application in IIS Its working perfectly. If any one can answer plz send the answer immediatly. Thank you

Upvotes: 0

Views: 231

Answers (2)

Ashish Gupta
Ashish Gupta

Reputation: 15139

Look for the Response.Redirect() calls in the page previous to the form you are getting the error. Just make sure that any harcoded URL for the form supplied to the Response.Redirect() call is correct.

EDIT.. Also, look for If you are navigating to a form which is in a different directory than the current one. For example:-

Response.Redirect("../SomeForm.aspx");

will redirect to an ASPX page just one level up of the current one. Each pair of dots implies one directory level up.

In thses cases, I think, you are better off using ~ (tilde) character which will always take the path from the root. So the mistakes happening because of incorrect number of dots can be minimised.Try something like this:-

Response.Redirect( this.ResolveUrl("~/Myfolder/SomeForm.aspx") );

More details for the ~ and ResolveUrl here.

This can also happen If you have window.location calls in javascript if you assign an incorrect URL to the same.

Upvotes: 0

Cristian Boariu
Cristian Boariu

Reputation: 9621

I assume that the urls for some of your pages are malformed. Check in your app how you are building the paths.

Personally, i use to have a class like PathsUtil, where i build all of my paths for the pages, so when i'm moving to IIS, it's extremely easy just to correct something (for instance add a virtual dir etc).

Update: - for the PathsUtil i use Paths.resx where i have defined all of my paths like

   Name             Value
index            /Site/index.aspx
add.user         /Site/addUser.aspx

and so on.

And in PathsUtil i only take the value from the Paths.resx and i build the url:

 string baseUrl = getBaseUrl() + (String)HttpContext.GetGlobalResourceObject("Paths", "index");

I've just moved to an IIS7 server, and there i've created a virtual dir "gramma" You can note that was a piece of cake only to add "/gramma" in Paths.resx, in front of each url :)

Upvotes: 2

Related Questions