2013-10-09 2 views
0

WebApplication에는 [WebMethod] 호출이 많이 있습니다. 보안을 위해 로그인 한 사용자인지 여부 (세션 사용 여부)를 확인하고자합니다. 어떻게 코드를 작성하지 않고도 확인할 수 있습니까? WebMethods?모든 WebMethod 요청에 대한 이벤트

예 : 내가 당신에게 예를 하여이 답을주고있다

[WebMethod] 
public static bool WebMethodCall() 
{// check if its a logged in user or not before executing the webmethod 
    return true; 
} 
+0

....... –

+0

@dholakiyaankit를하지만 볼'[의 WebMethod]'그래서 문제는 무엇 유효한 사용자 –

+0

에 대한 확인 나는 당신이 당신 webmethod에서 세션을 사용하여 확인할 수있는 일반적인 방법을 원해? –

답변

0

은 내가 웹 서비스라는 이름의 common.cs 이 지금

public class Common : System.Web.Services.WebService 
    { 


    public Common() 

     { 
      //here you can check your session so when ever your 
webmethod will be executed this code will call first then your webmethod 

     } 
//this webmethod will be executed after common 
     [WebMethod] 
     public static bool WebMethodCall() 
     {// check if its a logged in user or not before executing the webmethod 
       return true; 
     } 
[WebMethod] 
     public static bool WebMethodCall1() 
     {// check if its a logged in user or not before executing the webmethod 
       return true; 
     } 
    } 

그래서 explaination 당신이 일반적인 클래스 일반적인 두의 WebMethod 명명 한이 처럼 될 것입니다 webmethodcallwebmethodcall1 commo에 공통 코드를 추가하십시오. n 이것이 도움이되기를 바랍니다. :)

+0

그건 작동하지 않습니다 –

+0

그것이 작동합니다 귀하의 코드를 넣어 –

관련 문제