Using an MVC HtmlHelper from a WebForm

后端 未结 4 505
灰色年华
灰色年华 2020-12-01 05:28

I\'m in the process of adding some UI functionality to a hybrid WebForms/MVC site. In this case, I\'m adding some AJAX UI features to a WebForms page (via jQuery), and the

4条回答
  •  误落风尘
    2020-12-01 06:21

    I know this is an old question, but I ran into this issue today and thought I'd share. I'm working in MVC4 and have a webform control (.ascx) that's shared between both MVC (via RenderPartial) and WebForms. In that control, I needed an antiforgery token. Fortunately, there's a helper now you can use in your webforms now that's as simple as this:

    <%= AntiForgery.GetHtml() %>
    

    This will render your anti-forgery token like you would get in MVC.

    Here's the MS link to it.

提交回复
热议问题