asp.net - RequestContext.RouteData.Route vs Page.RouteData.Route -



asp.net - RequestContext.RouteData.Route vs Page.RouteData.Route -

im building high traffic asp.net webforms site. have componentized urls in class. when looking current route of request efficient? calling httpcontext.current.request.requestcontext.routedata.route or sending page.routedata.route method checks see if @ route url. example:

public static bool iscurrentroute(string routename) { var route = httpcontext.current.request.requestcontext.routedata.route; if (route == system.web.routing.routetable.routes[routename]) homecoming true; homecoming false; }

page.routedata wraps around context.routedata.

taken justdecompile

[designerserializationvisibility(designerserializationvisibility.hidden)] [browsable(false)] public routedata routedata { { if (base.context != null && base.context.request != null) { homecoming base.context.request.requestcontext.routedata; } homecoming null; } }

so reply question - no difference. though less exception if utilize page method due null checks. though how context going null question , perchance case want design if think has potential.

also rather accessing httpcontext.current straight think wrapping in httpcontextbase , using that.

an illustration can found here http://www.agileatwork.com/bolt-on-multi-tenancy-in-asp-net-mvc-with-unity-and-nhibernate/ @ line with

new httpcontextwrapper(httpcontext.current)

asp.net routes

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -