简体   繁体   中英

Why doesn't IIS7.5 show my default document with URL rewriting?

I'm using IIS7.5. I have a simple ASP.NET webforms site that uses basic URL rewriting in global.asax, intercepting requests for .aspx pages and passing them to various template pages.

For example, you can request http://www.mysite.com/default.aspx . In global.asax I first check if this exists as a "true" page. If it doesn't, I go off to the data store to get the details and redirect to template.aspx?page=default (or something similar).

This all works great. However, there's one issue. If I browse to http://www.mysite.com/default.aspx I get the page I expect. If I set the default document to default.aspx, either in the web.config or in IIS, then browse to http://www.mysite.com/ I get the error about directory browsing not being allowed.

Why is IIS ignoring the default document in this case? It appears to be because the file "default.aspx" doesn't exist. If this is the case, is there a workaround for the problem?

EDIT

To clarify, I don't have control over the IIS system and it's on really basic hosting, though I can request some changes, so I can't use any URL rewriting modules.

Workaround for you situation: Create Index.aspx as default document as physical file and redirect user to Default.aspx URL. So when user comes to mysite.com/ then index.aspx will kick in and force redirect to default.aspx which can then handle your template redirection logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM