2016-08-13 6 views
1

ページに複数のタブが含まれ、各タブでajaxメソッドを呼び出すページを実行して、独自のビューを取得します。asp.net mvcでajaxリクエストを実行しているときに、OnActionExecutingメソッドでルートページURLを取得する方法

私の問題は、Ajaxリクエストがコントローラに来てOnActionExecutingメソッドが来るときです。私はRoot(Page)URLを取得できません。あなたは、ヘッダーのコレクションから、元のURLを取得することができますhttp://www.myapp.com/Profile/ManageLocation

protected override void OnActionExecuting(ActionExecutingContext filterContext) 
    { 
     var url = new UrlHelper(filterContext.RequestContext); 
     string urlPath = url.Action();// Get current requested '/Action/Method' 

//How to get Root Page URL 

} 

答えて

0

よう

http://www.myapp.com/Profile/MyProfile AjaxのURLのような

ルートURL:

public override void OnActionExecuting(ActionExecutingContext filterContext) 
    { 
     var callFrom = filterContext.HttpContext.Request.Headers["Referer"]; 
     //Do something 
    } 
関連する問題