Servicestack Razor Self Host中的防伪令牌

时间:2013-10-22 07:49:07

标签: c# servicestack

我使用servicestack razor构建了一个应用程序。我通过一些cshtml视图自我托管应用程序。

我有一个模板,我想使用@Html.AntiForgeryToken();

渲染AntiForgery令牌

它在下面给出了一个错误:

Response Status

Error Code
        ArgumentException
Message
                An HttpContext is required to perform this operation. Check that this operation is being performed during a web request.

Stack Trace

 at ServiceStack.Html.AntiXsrf.AntiForgery.GetHtml()
 at ServiceStack.Html.HtmlHelper.AntiForgeryToken() at ASP.__Login.Execute()
 at ServiceStack.Razor.ViewPage.WriteTo(StreamWriter writer) 
 at ServiceStack.Razor.Managers.RazorPageResolver.ExecuteRazorPageWithLayout(IHttpRequest httpReq, IHttpResponse httpRes, Object model, IRazorView page, Func`1 layout) 
 at ServiceStack.Razor.Managers.RazorPageResolver.ResolveAndExecuteRazorPage(IHttpRequest httpReq, IHttpResponse httpRes, Object model, RazorPage razorPage) 
 at ServiceStack.Razor.Managers.RazorPageResolver.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) 
 at ServiceStack.WebHost.Endpoints.AppHostHttpListenerBase.ProcessRequest(HttpListenerContext context) 
 at ServiceStack.WebHost.Endpoints.Support.HttpListenerBase.ListenerCallback(IAsyncResult asyncResult)

有没有办法在servicestack razor的自托管页面上获取Antiforgery令牌?

0 个答案:

没有答案