Adding IIS UrlRewrite seems to break debugging on local IIS server

前端 未结 6 649
耶瑟儿~
耶瑟儿~ 2021-02-04 11:25

This issue is driving me insane: I was working on a recently created project and suddenly I was unable to debug that specific project.

I\'m using a local IIS 7.5 with t

相关标签:
6条回答
  • 2021-02-04 11:38

    I was having the same problem. I couldn't start my project to debug in visual studio. I followed more than one instruction you guys gave.

    First of all I had to create a rule to ignore the page /debugattach.aspx, just as @Kirk Woll said.

    Second, I had to follow the Doug instruction. My project was pointed to start action through the page "index.aspx", and my rule is created to remove the aspx extension. So, changing the start page to the page already formatted (with no .aspx) it worked perfectly.

    Ps. 1: I have more than 5 rules in my project, I've isolated one by one to identify which rule was causing the problem, and I figured out that the rule that was causing the problem was the rule that removes the aspx extension.

    Ps. 2: Even correcting the project start page, it still not working, it only worked when I added the rule that ignores the page /debugattach.aspx.

    Ps. 3: I hadn't to change any of my rules to match some pattern that I should ignore

    0 讨论(0)
  • 2021-02-04 11:46

    The problem is that all files will be forced to use a rule, unless they are explicitly excluded by a condition. I don't have the source code anywhere near me, but I guess this made the trick:

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

    The LowerCaseRule entry should look like this:

    <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> 
    
    0 讨论(0)
  • 2021-02-04 11:48

    I was having this issue and the solution was to add the host name to the site bindings in IIS and then change the project URL from http to https.

    0 讨论(0)
  • 2021-02-04 11:53

    I had a similar problem using VS 2010, IIS 7, and URLRewriter 2 and found a workaround - though hopefully someone will post a real solution for you.

    You can attach the debugger to the IIS process and debug as follows: 1. In Visual Studio, click Debug > Start without debugging 2. Set a breakpoint 3. Click Debug > Attach to Process.
    3. Check the "Show processes in all sessions" checkbox. 4. Highlight w3wp.exe (the iis worker process) and click "Attach" 5. In your browser, go to the url that will cause your breakpoint to be hit 6. In Visual Studio, the code should be paused at your breakpoint and you can step through as usual.

    0 讨论(0)
  • 2021-02-04 11:58

    I just discovered that the if the project URL you are using (right click your project, go to Properties, click on the Web tab on the left) happens to trigger your rewrite rule, then debugging using the play button won't work. The "fix" is to simply set your project URL to one that won't be rewritten.

    For example, I am using URL rewrite to make sure that HTTP requests get redirected to HTTPS. As long as my project URL begins with https:// then I have no issues debugging (apart from the fact that I have to install an SSL cert on my development machine, but that's easy to work around).

    0 讨论(0)
  • 2021-02-04 12:00

    Visual Studio, when starting up, will (for some reason) attempt to access the URL:

    /debugattach.aspx

    If you have a rewrite rule that redirects (or otherwise catches), say, .aspx files, somewhere else then you will get this error. The solution is to add this section to the beginning of your web.config's <system.webServer>/<rewrite>/<rules> section:

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

    This will make sure to catch this one particular request, do nothing, and, most importantly, stop execution so none of your other rules will get run. This is a robust solution, so feel free to keep this in your config file for production.

    0 讨论(0)
提交回复
热议问题