Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 28, 2012 05:55 PM by soygul
0 Points
3 Posts
Apr 25, 2012 11:59 AM|LINK
Trying to access the current URL as below succeeds in IIS host:
var uri = this.Url.Route(null, new { id = value.Id });
but throws 'ArgumentNullException' exception with self-host. The error message is: 'Value cannot be null. Parameter name: name' and stack trace:
at System.Web.Http.HttpRouteCollection.GetVirtualPath(HttpControllerContext controllerContext, String name, IDictionary`2 values) at System.Web.Http.Routing.UrlHelper.GetHttpRouteHelper(HttpControllerContext controllerContext, String routeName, IDictionary`2 routeValues) at System.Web.Http.Routing.UrlHelper.GetHttpRouteHelper(HttpControllerContext controllerContext, String routeName, Object routeValues) at System.Web.Http.Routing.UrlHelper.Route(String routeName, Object routeValues) at MyProj.Services.DataService.Controllers.MessageController.Post(MessageDto value) in C:\...\MessageController.cs:line 93 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments) at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0() at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
Everything else seems to work otherwise and all routes are correctly set-up. Is this a bug? Any ideas?
Member
475 Points
99 Posts
Apr 25, 2012 12:34 PM|LINK
I suspect that this is because there is no httpcontext in a self-hosted environment.
Apr 25, 2012 12:39 PM|LINK
Also, are you meaning to pass null as the route name?
Apr 25, 2012 12:54 PM|LINK
Yes basically you can't pass
Route(routeName = null, ...)
and I'm curious as to why it does work with IIS and not self-host.
All-Star
45864 Points
7713 Posts
MVP
Apr 28, 2012 01:32 PM|LINK
http://forums.asp.net/t/1789334.aspx/1/10
Apr 28, 2012 05:55 PM|LINK
Yes I've noticed the behavioral differences between ASP.NET host and self-host. I'll see what happens w/ the RTM.
soygul
0 Points
3 Posts
Self-host this.Url.Route
Apr 25, 2012 11:59 AM|LINK
Trying to access the current URL as below succeeds in IIS host:
var uri = this.Url.Route(null, new { id = value.Id });but throws 'ArgumentNullException' exception with self-host. The error message is: 'Value cannot be null. Parameter name: name' and stack trace:
at System.Web.Http.HttpRouteCollection.GetVirtualPath(HttpControllerContext controllerContext, String name, IDictionary`2 values)
at System.Web.Http.Routing.UrlHelper.GetHttpRouteHelper(HttpControllerContext controllerContext, String routeName, IDictionary`2 routeValues)
at System.Web.Http.Routing.UrlHelper.GetHttpRouteHelper(HttpControllerContext controllerContext, String routeName, Object routeValues)
at System.Web.Http.Routing.UrlHelper.Route(String routeName, Object routeValues)
at MyProj.Services.DataService.Controllers.MessageController.Post(MessageDto value) in C:\...\MessageController.cs:line 93
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
Everything else seems to work otherwise and all routes are correctly set-up. Is this a bug? Any ideas?
jdothoffman
Member
475 Points
99 Posts
Re: Self-host this.Url.Route
Apr 25, 2012 12:34 PM|LINK
I suspect that this is because there is no httpcontext in a self-hosted environment.
-Blog
jdothoffman
Member
475 Points
99 Posts
Re: Self-host this.Url.Route
Apr 25, 2012 12:39 PM|LINK
Also, are you meaning to pass null as the route name?
-Blog
soygul
0 Points
3 Posts
Re: Self-host this.Url.Route
Apr 25, 2012 12:54 PM|LINK
Yes basically you can't pass
and I'm curious as to why it does work with IIS and not self-host.
imran_ku07
All-Star
45864 Points
7713 Posts
MVP
Re: Self-host this.Url.Route
Apr 28, 2012 01:32 PM|LINK
http://forums.asp.net/t/1789334.aspx/1/10
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
soygul
0 Points
3 Posts
Re: Self-host this.Url.Route
Apr 28, 2012 05:55 PM|LINK
Yes I've noticed the behavioral differences between ASP.NET host and self-host. I'll see what happens w/ the RTM.