2010-07-08 5 views
2

반복, I 변환 친화적 인 URL을 만들었습니다IIS URL 재 작성은 - 친절한 URL : 쿼리 문자열 변수가 내 IIS 7 구성에서

http://mysite/restaurant.aspx?Name=SomeName 

이 작업을 수행하는

http://mysite/SomeName 

에, 내가 가지고있는 다음과 같은 규칙 :

<rule name="RedirectUserFriendlyURL1" enabled="true" stopProcessing="true"> 
    <match url="^Restaurant\.aspx$" /> 
    <conditions> 
     <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> 
     <add input="{QUERY_STRING}" pattern="^Name=([^=&amp;]+)$" /> 
    </conditions> 
    <action type="Redirect" url="{C:1}" appendQueryString="false" /> 
</rule> 

<rule name="RewriteUserFriendlyURL1" enabled="true" stopProcessing="false"> 
    <match url="^([^/]+)/?$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     <add input="{REQUEST_FILENAME}" pattern=".aspx" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="Restaurant.aspx?Name={R:1}" appendQueryString="false" /> 
</rule> 
  1. 위합니까는 achie하는 것이 올바른 것 같다 내가 뭘하려고하는지? 어떤 이유
  2. , 모든 포스트 백에 내가 얻을 : 나는 false로 appendQueryString를 설정 한

    http://somesite/SomeName?Name=SomeName

참고.

답변

6

양식 다시 게시 작업은 원시 URL이 아닌 기본 URL을 사용합니다.

간단한 솔루션 (I는 서버 측 폼 액션 속성은 3.5에서만 사용할 수 있습니다 생각) :

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!String.IsNullOrEmpty(Request.ServerVariables["HTTP_X_ORIGINAL_URL"])) 
    { 
     form1.Action = Request.ServerVariables["HTTP_X_ORIGINAL_URL"]; 
    } 
} 

http://blogs.iis.net/ruslany/archive/2008/10/23/asp-net-postbacks-and-url-rewriting.aspx