这个问题使我发疯:我正在开发一个最近创建的项目,突然间我无法调试该特定项目。

我正在使用带有IIS UrlRewrite 2模块的本地IIS 7.5。我的开发计算机是带有Visual Studio 2010 Professional的Windows 7 x64。

在其他项目中的调试仍然可以进行。我已经在本地IIS中设置了一个条目,然后开始在本地IIS上调试ASP.net 4.0项目。
我可以使用URL Rewrite 2模块跟踪调试问题到意外行为,并使用新创建的4.0 Web应用程序项目重现该问题:

在IIS中使用管理设计器添加了简单的 URL重写规则之后,由于收到错误消息,因此无法开始调试

Unable to start debugging on the web server. Could not start ASP.Net debugging.
More information may be available by starting the project without debugging.

(我也曾尝试从其他项目复制URL重写设置,但到目前为止没有成功)
在没有调试的情况下启动项目可以完美地进行,并且不会显示任何错误!

除此之外,我只在default.aspx的默认文本中添加了一些字符。

在IIS中的站点设置:
-我创建了一个新站点,并像往常一样分配了绑定(bind)(该端口无关紧要,例如我尝试使用端口86)。
-我将新创建的应用程序池中的用户身份设置为“networkservice”
-将新创建的应用程序池的框架版本设置为“4.0”
-我已授予用户'networkservice'对解决方案目录的完整目录权限

我还尝试了其他几种设置组合,例如启用的WindowsAuthentification,FormsAuthentication等。到目前为止没有运气。

这是项目的 Web选项卡:
服务器:使用本地IIS Web服务器,项目地址为“http://localhost:86/”(我也尝试使用“http://localhost:86”,似乎没有什么不同)

这里发生了什么?我在这里迷失了方向。有想法该怎么解决这个吗? (不选择不使用UrlRewrite 2.0模块)

最后是 web.config :
<?xml version="1.0" encoding="UTF-8"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true" />
        <rewrite>
            <rules>
                <rule name="LowerCaseRule1" stopProcessing="true">
                    <match url="[A-Z]" ignoreCase="false" />
                    <action type="Redirect" url="{ToLower:{URL}}" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
</configuration>

更新:
显然,我可以使用ActionType =“Rewrite”进行调试,但不能使用ActionType =“Redirect”进行调试。不过,仍然没有真正的选择,因为我希望该问题首先解决,并且不要通过某些解决方法来解决。我现在真的很想提供赏金,但是系统不允许我这样做。

有人可以重现我的脚步吗? (到目前为止,我已经在2台不同的计算机上获得了此密码)

最佳答案

Visual Studio在启动时将(出于某种原因)尝试访问URL:



如果您有一个重写规则来重定向(或捕获).aspx文件,例如web.config文件,那么您将收到此错误。解决方案是将此部分添加到<system.webServer>/<rewrite>/<rules>的ojit_code部分的开头:

<rule name="Ignore Default.aspx" enabled="true" stopProcessing="true">
    <match url="^debugattach\.aspx" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="None" />
</rule>

这将确保捕获该特定请求,不执行任何操作,并且最重要的是,停止执行,以便其他任何规则都不会运行。这是一个可靠的解决方案,请随时将其保存在配置文件中以进行生产。

关于c# - 添加IIS UrlRewrite似乎会中断本地IIS服务器上的调试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5302317/

10-12 00:01
查看更多