2011-01-28 1 views
0

이 간단한 질문해야한다,하지만 난 .net에서 초보자 그리고 난 페이지 이벤트에 대한 VB 코드를 사용하여, 다른 포럼에서 모든 솔루션 등어떻게 무시할 수 있습니다 ";" ASP.net에서 URL의 매개 변수?

내가 asp.net에서 일하고을 발견하지 않았습니다. 나는 디버깅을 위해 localhost 서버를 사용하고있다.

내 사이트를로드하기 위해 (액세스 할 수없는 다른 서버의) 인트라넷에서 3 부분 사용자 인증자를 사용하고 있습니다. 이 인증자는 사용자 로그인을 확인하고 내 페이지가 URL의 사용자 데이터를 전달하도록 호출합니다. 그러나 URL에 ? 앞에 ;jsessionid=null 문이 포함되어있어 내 페이지로드가 엉망입니다. 브라우저에서 나타나는 메시지는 다음과 같습니다

Server Error in '/' Application. 
    The resource cannot be found. 
    Description: HTTP 404. The resource you are looking for (or one of its 
       dependencies) could have been removed, had its name changed, or 
       is temporarily unavailable. Please review the following URL 
       and make sure that it is spelled correctly. 
    Requested URL: /page.aspx;jsessionid=null 

예 : 인증 호출 :

"http://localhost:61932/page.aspx;jsessionid=null?param1=data1&param2=data2" 

내가 함께 테스트하는 경우 :

"http://localhost:61932/page.aspx?param1=data1&param2=data2" 

그것의 확인을 클릭합니다. 그러나 jsessionid=null이 나타나면 오류가 발생합니다.

그것은 jsp 페이지 향하는 인수 jsessionid 것 같다,하지만 난 .net이 하나를 무시 달성하고 있지 않다.
세션을 고려하거나 서버를 구성하는 등의 작업을 수행할까요?

+1

어떤 서버를 사용하고 있습니까? IIS 6? 7? 7.5? 아파치와 mod_mono? 다른 것? – Oded

+1

질문을 반복하십시오. ';'다음에 나오는 매개 변수 만 무시하고 싶습니다. ??? –

+0

"jsessionid = null"매개 변수 만 무시하고 URL의 일반적인 쿼리 매개 변수를 유지하려고합니다. 나는 그들을 사용하여 사용자를 식별해야합니다. – Alex

답변

1

요청 경로에서 jsession 토큰을 제거하는 IHttpModule을 구현할 수 있습니다. 간단한 구현은 다음과 같습니다

public class RemoveSemicolonModule : IHttpModule 
{ 
    private static Regex regex = new Regex("\\;[^\\?]+"); 

    public void Init(HttpApplication context) 
    { 
     context.BeginRequest += RemoveSemicolon; 
    } 

    private void RemoveSemicolon(object sender, EventArgs e) 
    { 
     HttpApplication application = (HttpApplication)sender; 
     string path = application.Context.Request.Url.PathAndQuery; 

     var match = regex.Match(path); 

     if (match.Success) 
     { 
      path = path.Remove(match.Index, match.Length); 

      // Add the jSessionToken to the request context, so it is still accessible at a later stage. 
      application.Context.Items["jSessionToken"] = match.Value; 
     } 

     application.Context.RewritePath(path); 
    } 

    public void Dispose() {} 
} 

당신은 당신의 web.config 파일에 HttpModule을 등록해야합니다. 자세한 내용은 this page을 참조하십시오.

1

URL rewriting module에서 IIS 7/7.5보기를 사용하는 경우 - 당신은 내 의견으로는 단지 ;을 무시보다 더 나은 될 것 ;jsessionid=null을 밖으로 제거하는 규칙을 작성할 수 있어야합니다.

IIS 6의 경우 동일한 효과를 낼 수있는 third party URL rewriters이 있습니다.

관련 문제