错误消息文件'WebResource.axd.aspx'不存在

问题描述 投票:0回答:1

我可以看到问题已经存在,但尚未回答。我收到此错误,但无法正确重定向。错误消息:文件“ /WebResource.axd.aspx”不存在。

我正在web.config中使用url重写,因此可能会导致此问题。如何排除不应该重定向到aspx扩展名的aspx以外的文件?以下是我的web.config:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<rewrite>
  <rules>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true"/>
      </conditions>
      <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/>
    </rule>
    <rule name="RewriteASPX">
      <match url="(.*)"/>
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
      </conditions>
      <action type="Rewrite" url="{R:1}.aspx"/>
    </rule>
  </rules>
</rewrite>

c# url-rewriting web-config
1个回答
0
投票

得到的答案只是在规则中添加了一个以避免axd,asmx并有效。

 <system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<rewrite>
  <rules>

    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true"/>
        <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true"/>
      </conditions>
      <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/>
    </rule>

    <rule name="RewriteASPX">
      <match url="(.*)"/>
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
      <add input="{URL}" pattern="^.+\.((axd)|(js)|(xaml)|(asmx))/populateData" negate="true" /> 
      </conditions>
      <action type="Rewrite" url="{R:1}.aspx"/>
    </rule>
  </rules>
</rewrite>

© www.soinside.com 2019 - 2024. All rights reserved.