在集线器上调用方法时,我现在收到下面最后一行的错误。这之前没有发生过。我正在使用T4MVC。
错误
Additional information: Response is not available in this context.
集线器
public void Viewing()
{
var urlHelper = new UrlHelper(Context.Request.GetHttpContext().Request.RequestContext);
var url = urlHelper.Action(MVC.Directors.EventSchedule.Index(EventId));
检查Response
对象的RequestContext
会给我:'(request.HttpContext).Response' threw an exception of type 'System.Web.HttpException'
堆栈跟踪
at System.Web.HttpContext.get_Response()
at System.Web.HttpContextWrapper.get_Response()
at System.Web.UI.Util.GetUrlWithApplicationPath(HttpContextBase context, String url)
at System.Web.Routing.RouteCollection.NormalizeVirtualPath(RequestContext requestContext, String virtualPath)
at System.Web.Routing.RouteCollection.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
at System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values, Boolean& usingAreas)
at System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea(RouteCollection routes, RequestContext requestContext, String name, RouteValueDictionary values)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.RouteUrl(String routeName, RouteValueDictionary routeValues, String protocol, String hostName)
at System.Web.Mvc.T4Extensions.Action(UrlHelper urlHelper, ActionResult result, String protocol, String hostName)
at System.Web.Mvc.T4Extensions.Action(UrlHelper urlHelper, ActionResult result)
at Tournaments.Models.Mvc.SignalR.ScheduleHub.Viewing() in f:\My Webs\...\ScheduleHub.cs:line 113
at lambda_method(Closure , IHub , Object[] )
at Microsoft.AspNet.SignalR.Hubs.HubMethodDispatcher.<>c__DisplayClass1.<WrapVoidAction>b__0(IHub hub, Object[] parameters)
at Microsoft.AspNet.SignalR.Hubs.HubMethodDispatcher.Execute(IHub hub, Object[] parameters)
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.Incoming(IHubIncomingInvokerContext context)