繁体   English   中英

添加IIS UrlRewrite似乎打破了本地IIS服务器上的调试

[英]Adding IIS UrlRewrite seems to break debugging on local IIS server

这个问题让我感到疯狂:我正在研究最近创建的项目,突然间我无法调试该特定项目。

我正在使用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-Rewrite设置,到目前为止没有成功)
在没有调试的情况下启动项目可以完美地工作,并且不会显示任

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

IIS中的站点设置
- 我创建了一个新站点,分配了一个绑定(哪个端口无关紧要,例如我尝试了端口86),就像我一直这样。
- 我将新创建的应用程序池中的用户标识设置为“networkservice”
- 将新创建的应用程序池的框架版本设置为“4.0”
- 我已将用户'networkservice'完整目录权限授予解决方案目录

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

这是项目的Web选项卡
服务器:使用本地IIS Web服务器,项目URL“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:

/debugattach.aspx

如果你有一个重写规则,重定向(或以其他方式捕获),比如.aspx文件,在其他地方,那么你将得到这个错误。 解决方案是将此部分添加到web.config<system.webServer>/<rewrite>/<rules>部分的开头:

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

这将确保捕获这一个特定请求,什么都不做,最重要的是,停止执行,这样就不会运行任何其他规则。 这是一个强大的解决方案,因此请随意将其保存在配置文件中以进行生产。

我刚刚发现,如果您正在使用的项目URL(右键单击您的项目,转到属性,单击左侧的Web选项卡)会触发您的重写规则,然后使用播放按钮进行调试将无法正常工作。 “修复”只是将项目URL设置为不会被重写的URL。

例如,我使用URL重写来确保HTTP请求被重定向到HTTPS。 只要我的项目URL以https://开头,那么我就没有问题调试(除了我必须在我的开发机器上安装SSL证书这一事实,但这很容易解决)。

我遇到了同样的问题。 我无法启动我在Visual Studio中调试的项目。 我跟着你们给了不止一条指令。

首先,我必须创建一个规则来忽略页面/debugattach.aspx,就像@Kirk Woll所说的那样。

其次,我必须遵循道格指示。 我的项目指向通过页面“index.aspx”开始操作,我的规则被创建以删除aspx扩展。 因此,将起始页面更改为已格式化的页面(没有.aspx),它可以完美地工作。

PS。 1:我的项目中有超过5个规则,我已经逐个隔离以确定导致问题的规则,并且我发现导致问题的规则是删除aspx扩展的规则。

PS。 2:即使纠正项目开始页面,它仍然无法正常工作,只有在我添加了忽略页面/debugattach.aspx的规则时才有效。

PS。 3:我不得改变我的任何规则以匹配一些我应该忽略的模式

问题是所有文件都将被强制使用规则,除非条件明确排除它们。 我没有附近的源代码,但我想这就是诀窍:

  <conditions>
    <add input="{URL}" matchType="Pattern" pattern="^.+\.((axd)|(js)|(xaml))$" ignoreCase="true" negate="true"/>
  </conditions>

LowerCaseRule条目应如下所示:

<rule name="LowerCaseRule1" enabled="true" stopProcessing="true">
  <match url="[A-Z]" ignoreCase="false"/>
  <conditions>
    <add input="{URL}" matchType="Pattern" pattern="^.+\.((axd)|(js)|(xaml))$" ignoreCase="true" negate="true"/>
  </conditions>
  <action type="Redirect" url="{ToLower:{URL}}"/>
</rule> 

我遇到了这个问题,解决方案是将主机名添加到IIS中的站点绑定,然后将项目URL从http更改为https。

我在使用VS 2010,IIS 7和URLRewriter 2时遇到了类似的问题并找到了解决方法 - 但希望有人会为您发布真正的解决方案。

您可以将调试器附加到IIS进程并按如下方式进行调试:1。在Visual Studio中,单击“调试”>“启动而不调试”2.设置断点3.单击“调试”>“附加到进程”。
3.选中“在所有会话中显示进程”复选框。 4.突出显示w3wp.exe(iis工作进程)并单击“附加”5.在浏览器中,转到将导致断点被触发的URL 6.在Visual Studio中,应在断点处暂停代码你可以照常上班。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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