Url routing and IIS7 03-24-2011 04:24 PM
Hi,
I have a query regarding Url Routing in asp.net 4.0 and IIS7. Below I have explained what is my website structure and how it is configured in IIS7.
Directory Structure:
1.MyWebsite>Index.aspx
2.MyWebsite>AboutUs>Index.aspx
3.MyWebsite>ContactUs>ContactUs.aspx
II7 Configuration:
I have configured my application's default document as Index.aspx Now, when i access below urls, IIS7 does few routing automatically (note that until now i havent added any routes in global.asax )
1.localhost/MyWebsite will be forwarded to localhost/MyWebsite/Index.aspx Ok !!
2.localhost/MyWebsite/Aboutus will be forwarded to localhost/AboutUs/Index.aspx (this redirection is done as parent level default document is inherited by AboutUs folder) Ok !!
3.localhost/MyWebsite/ContactUs == Http Error 403.14 Forbidden (This error is thrown by IIS7 becoz it doesnt find Index.aspx in Conactus folder) Fine !!
Ok so for localhost/MyWebsite/ContactUs to be routed to localhost/MyWebsite/ContactUs/Index.aspx I added below code in RegisterRoutes() method in global.asax hoping this will fulfill my requirement.
routes.MapPageRoute('ConactUs','ContactUs','~/ContactUs/ContactUs.aspx');
So now when i acces localhost/MyWebsite/ContactUs i still get the same Forbidden error. So is IIS7 default page setting at root not allowing my routes to work?
If I have Index.aspx page in each folder then it works i.e.redirection to /Contactus/Index.aspx ... but what if i dont have Index.aspx (my default document) in every page?
Thanks & Kind regards, m .
Ok here is what i did to work things for me. First of all let me again add few more details about my project..
Directory Structure:
1.MyWebsite>Index.aspx
2.MyWebsite>AboutUs>Index.aspx
3.MyWebsite>ContactUs>ContactUs.aspx
All my pages have a UserControl named logo.ascx. logo.ascx doesnt have a code behind file attached to it. It just have a html with resolve.clienturl() method. And logo.ascx just have below attribute; <%@ Control Language="C#" %>
So to make every thing working i did a couple of things,
Thanks naraen thanks pauli for ur support and suggestions.