1

When calling a method on a hub I am now getting an error for the last line below. This wasnt happening before. I am using T4MVC.

Error

Additional information: Response is not available in this context.

Hub

public void Viewing()
        {
            var urlHelper = new UrlHelper(Context.Request.GetHttpContext().Request.RequestContext);
            var url = urlHelper.Action(MVC.Directors.EventSchedule.Index(EventId));

Checking the Response of the RequestContext object gives me: '(request.HttpContext).Response' threw an exception of type 'System.Web.HttpException'

Stack Trace

   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)
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

0 Answers0