2017-05-03 84 views
0

我有一個帶有url重寫規則的asp.net頁面。規則顯示如下:使用url重寫時ASP.NET頁面加載兩次

<rule name="DiscoverCategorySEO"> 
     <match url="^Discover/([0-9]+)/"/> 
     <conditions> 
     <add input="{URL}" negate="true" pattern="\.axd$"/> 
     </conditions> 
     <action type="Rewrite" url="News/Discover.aspx?Section={R:1}" redirectType="Permanent" appendQueryString="false"/> 
</rule> 

我在Page_Load方法中放置了一個斷點用於調試。然後當我訪問'http://[domain]/Discover/1/'時發現。發現頁面將加載兩次。但是,如果我把'http://[domain]/News/Discover.aspx?Section=1」,破發點僅會被擊中。

有誰知道我怎麼能保持URL重寫規則,只有一次同時加載頁面?

+0

看起來像你需要say stopprocessing = true –

+0

Hi鬍子的駱駝,我在哪裏添加這個? –

+0

它是一個屬性在那裏...嘗試動作元素... intellisense會引導你;) –

回答

0
<rule name="DiscoverCategorySEO" enabled="true" stopProcessing="true"> 
    <match url="^Discover/([0-9]+)/"/> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{URL}" negate="true" pattern="\.axd$"/> 
      <add input="{PATH_INFO}" pattern="^Discover/([0-9]+)/" /> 
      </conditions> 
      <action type="Rewrite" url="News/Discover.aspx?Section={R:1}" redirectType="Permanent" appendQueryString="false"/> 
</rule> 
+0

嗨,約瑟夫,謝謝你的回覆。代碼你給了,但它仍然打破了兩次。 –

+0

你重置了iis嗎? –

+0

嗨我已經調整了答案,這對你好嗎? –