Web.Config Question

liunx

Guest
I'm working on my first website, and it appears the web.config file isn't working outside of Visual Studio 2005.

In VS, I can run the project, and it takes me to a login page when I go to my support area. When I click on a link that I intentionally made as an error, it takes me to my default error page. Both of which are set-up in web.config. But, when I try to open my website by going to the location of my homepage.htm file and clicking on it, neither one works.

I've looked into publishing, and it appears that my problem is probably similar. For some reason, the web.config is just not attached to my project. So does anyone know how to make my pages follow the configurations I made in web.config?

Any help or suggestions are appreciated.re-create your webpage.
click on the aspx page you want to be your start page, right click it ans "set as start page".The .aspx page isn't my start page. Anonymous users can access my homepage and all areas except the support pages.yawnzzzz you should create them all as ASP.net pages using masterpages to keep a consistent site. However you can use the "location" tag in the web.config to control access with roles/users. You have to have all pages ASP.net or configure IIS to force all requests to the ASP.net engine.How do I configure IIS to force all requests to the ASP.net engine?you have to configure it in the mime extnesionsI switched my extensions to .aspx, and everything is working correctly now when I run through IIS on my computer, but when I load it up on our test server I have the same problem still.Did you also upload the web.config file?

~ mellamokbThe web.config is uploaded.
This file is located in a folder with homepage.aspx and error.htm.
My homepage has a link that I made incorrect to test my error page (error.htm), but when I click on it, it takes me to a generic IE HTTP 404 Not Found error page saying that it didn't find my link (it doesn't say it didn't find my error page). Here's my web.config code:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
<appSettings />
<connectionStrings />

<system.web>
<authorization>
<allow users="*" />
</authorization>
<compilation debug="true" />
<authentication mode="Forms">
<forms loginUrl="/loginForm.aspx" timeout="10" cookieless="AutoDetect" protection="All" />
</authentication>
<customErrors mode="On" defaultRedirect="error.htm">
</customErrors>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="homepage.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>Just as an extra check, I changed the link to "error.htm" and it went to my error page, so there's nothing wrong with that address.The error catching in web.config is for asp.net errors, not HTTP errors. HTTP errors are configured in IIS, because they are taken care of before the asp.net engine is ever reached.

When u say u click on link and get HTTP 404, I take it to mean ur linking to a page that doesn't exist; ilke say ur files on the remote server are like this:

homePage.aspx
causesError.aspx
error.htm

and u have a link on homePage.aspx to iamapage.htm, which doesn't exist. That's what i understand u to say. If you really want to test web.config, see above how I have a page called causesError.aspx. Create a page like that, and put an asp.net error into the source code of the page, like:

int x = 0 / 0; // division by zero

and then link to causesError.aspx, which is a real page (so won't cause HTTP 404) but has a compilation error, then u should see ur error page (error.htm) as expected. Am I understanding u right on this?

~ mellamokbYou understood what I was trying to do. I followed your advice and created a page with int x=0/0, and the page would load with just a warning at the bottom saying that the page had errors on it. The thing that confuses me is that when I load my webpage from IIS on my computer or through Visual Studios 2005, it went to my custom errors page when I had that HTTP error, but when I upload it onto my company's test server it seems to ignore everything in the web.config file.

I've been trying to solve this problem with the error page because there's less variables involved, but I also have a login form that's triggered in my web.config that doesn't work on the server. Like the error page, it works when run through IIS on my computer or through VS 2005, but it doesn't work when loaded on our test server.

The people in charge of the test server are rarely in contact with me and have little information on it... so I'm on my own, and this is my first website. Could this be caused by them having an older version of IIS on their test server or having an older version of .net? And if so, is there anything I can do about it?The thing that confuses me is that when I load my webpage from IIS on my computer or through Visual Studios 2005, it went to my custom errors page when I had that HTTP error


I think u might be right, asp.net does catch HTTP errors. Sorry for my incorrect explanation.

As far as your problem, I think I have a solution. Based on my experience, I've noticed that the security settings for shared hosted websites don't allow u to setup custom errors in web.config. Most of the time test servers are at a much lower security setting because they are not being used by people that are going to attack it.

The way I did the security in this situation was to use the Page.OnError function. Here is a document that explains very well how to perform this from beginning to end. I did this on our shared hosting, and it has worked great ever since!

<!-- m --><a class="postlink" href="http://aspnetresources.com/articles/CustomErrorPages.aspx">http://aspnetresources.com/articles/Cus ... Pages.aspx</a><!-- m -->

Read the part about "Trapping Errors On Page Level", because if u use any other sections, they are application-wide or require more security freedom than most shared hosting will allow. It is a little involved, so post any questions u have and I'll try to answer them.

Hope this helps!

~ mellamokbIt can. If you configure the MIME to point to handle all requests. First off if your using ASP.net 2.0 you can create an HttpHandler to do that for you.I've taken a step away from this project lately because I'm still completely stuck. There's another issue that's related, and why I can't just try a different approach. My webpage also has a support area where a username and password is needed. Just like the custom error page, it works correctly in Visual Studio 2005 and IIS 7.0 on my computer but doesn't work correctly on the test server. On the test server, instead of bringing up the Login URL specificed in web.config, it takes me directly to my support pages. I've been focusing on the custom errors because I think the two are related, and there's less possible reasons for the custom errors to not be working...

Do any of you think this is related to my website being created with .net 2.0 and IIS 7.0 because I'm getting to the point where my company might just buy our own server since I have no control over the software on the test server (which is rented by our parent company).No. Its not related to it.

You can write a HTML handler to it using ASP.net 2.0. HttpHandler or HttpModule. They work a bit different but either way it is possible to do what you want.No. Its not related to it.

You can write a HTML handler to it using ASP.net 2.0. HttpHandler or HttpModule. They work a bit different but either way it is possible to do what you want.

Well, I just got back to this problem, and I've never used HttpHandler's that I know of yet. So could you elaborate on what you mean? This was my first website, so I'm learning as I go.You can create an ASP.net handler dll in a sperate project and register it in the web.config.

<!-- m --><a class="postlink" href="http://msdn2.microsoft.com/en-us/library/zec9k340(VS.71">http://msdn2.microsoft.com/en-us/library/zec9k340(VS.71</a><!-- m -->).aspx

Older article but still works the same for the most part.You can create an ASP.net handler dll in a sperate project and register it in the web.config.

<!-- m --><a class="postlink" href="http://msdn2.microsoft.com/en-us/library/zec9k340(VS.71">http://msdn2.microsoft.com/en-us/library/zec9k340(VS.71</a><!-- m -->).aspx

Older article but still works the same for the most part.

I found this more indepth article discussing http handlers. Is this what you meant because it's really not what I'm looking for.

<!-- m --><a class="postlink" href="http://www.15seconds.com/issue/020417.htm">http://www.15seconds.com/issue/020417.htm</a><!-- m -->

If anyone else has an idea of why my website works on my own computer (in VS and IIS) but not on the server, then please feel free to say them. There's no guarantees that I didn't forget to do something simple because it is my first website, and I'm pretty much learning everything by just doing it. If there's something that could be stopping it on the server-end, then feel free to tell me as well. Everything works on the site on the server except for the login page and error page, which are both configured in the web.config file.Doesn't work isn't a description.are you using IIS 7 specific stuff? Can we see the code?are you using IIS 7 specific stuff? Can we see the code?

It's not IIS 7 specific. I originally did the code in VS 2005 on Vista, but I just loaded it up in VS 2003 on XP and it works fine on my computer. The code is huge, so which part would be helpful. I posted the web.config already in this, and everything else works fine except the login form and the error page. Neither one is triggered, so it's like the entire web.config is just being ignored.The pages must be ASp.net pages otherwise the events fire but you have no control over the error handling because the page is just served.Also i would use Health Monitoring in ASP.net webconfig it works wonders, gives you emails when there are compile time errors & every other type.
 
Back
Top