开发者

Routes Rewrite issue in IIS7

I am using IIS7 / C# / WebForms / .net Framework 3.5 I am using Routes in my web.config Here is a routes section

<system.webServer>
  ..
  <rewrite>
     <rules>

    <rule name="LoginRuleRewrite" stopProcessing="true">
        <match url="^Employee/Login$" />
        <action type="Rewrite" url="WebForms/Employees/Login.aspx" redirect开发者_运维技巧Type="Permanent" />
    </rule>
    </rules>
  </rewrite>

Now when open my page http://localhost/Employee/Login it displays the login form correctly from /WebForms/Employees/Login.aspx directory. But When I click the Login button, I get 404 error that "Requested URL /Employee/Login.aspx was not found"

Why is this happening? while it displays the form correctly, On Submit why it goes to /Employee/Login.aspx instead of /WebForms/Employee/Login.aspx

FYI, this application is working fine under IIS7.5. Issue is with IIS7.


Your 'match' line will not match /Employee/Login.aspx. It will only match if the .aspx extension is not present. You should go for something like this:

<rule name="LoginRuleRewrite" stopProcessing="true">
    <match url="^Employee/Login(\.aspx)?$" />
    <action type="Rewrite" url="WebForms/Employees/Login.aspx" redirectType="Permanent" />
</rule>

Thanks to LazyOne for the updated regex

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜