Get current controller in view

后端 未结 7 859
北荒
北荒 2020-12-04 11:55

I have a View - _Edit which lives in News M/V/C.

I reuse the V/M via the CategoryController as:

r         


        
7条回答
  •  渐次进展
    2020-12-04 12:28

    I have put this in my partial view:

    @HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString()
    

    in the same kind of situation you describe, and it shows the controller described in the URL (Category for you, Product for me), instead of the actual location of the partial view.

    So use this alert instead:

    alert('@HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString()');
    

提交回复
热议问题