How To Get Route Name From RouteData
Oct 17, 2010
I have several routes defined in my Global.asax; now, when I'm on a page I need to figure out what is the route name of the current route, because route name drives my site menu. I can't find a way to get current route name.
View 4 Replies
Similar Messages:
Mar 13, 2011
I tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax
Currently I use several routes for webfroms. routs template are like below
routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")
I encounter error, when I add below lines to global.asax
routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)
I want to know how could I mix ASp.Net MVC routes with webforms routes.
View 3 Replies
Oct 26, 2010
I am building a simple performance logger that hooks in to Application_EndRequest / Application_BeginRequest
I would like to send my logger the name of the action and controller as some sort of key.
How can I access this information? (Don't mind if I have to intercept it earlier on and keep it around in the context)
View 1 Replies
Jun 29, 2010
My web site has a handler (FileDownload.ashx) that deals with all file download requests. I've recently migrated my site to ASP.Net 4.0, and it now uses routing extensively. Everything works fine when dealing with page requests (aspx), but it's not working with my handler - I encounter the following error:
Type '<snip>.Handlers.FileDownload' does not inherit from 'System.Web.UI.Page'.
This makes sense, as routing is only implemented in the page. So, my question is, what steps do I need to take to be able to use routing and my ASHX together? I want to be able to extract RouteData.Values from the url.
public class FileDownload : IHttpHandler
{
}
View 2 Replies
Jan 7, 2011
Is there any ways to create our own RouteData from a URL string in asp.net mvc?
for example I have a URL string like this.
Url: http://localhost/supports/online chat?operator=A
From RouteData, I can find what is controller and action name.
but I have no idea to put it in RouteData.
View 3 Replies
Mar 9, 2010
when i run the app i got this error
A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name
this is my AdminAreaRegistration
[Code]....
View 2 Replies
Jul 29, 2010
Although I'm not using routing in an MVC application, this post seems to fit best here :)
I'm trying to access the datatokens that I've passed with the MapPageRoute-method and in a simple Webforms page it works, but in Application_AuthorizeRequest it seems like it's not populated yet.. DataTokens.Count returns 0 although I have passed one item
Is there an alternate way to access the DataTokens? The routing has initialized (it seems), because there's a major difference between url's that is mapped and one that's not..
From the regular Webforms page I'm using Page.RouteData.DataTokens["PagesID"] and in the global.asax file I'm using Request.RequestContext.RouteData.DataTokens["PagesID"]
View 10 Replies
Mar 30, 2011
How I can access the mvc RouteData in the CreateKernel override when using ninject.web.mvc extension and inheriting NinjectHttpApplication?
[Code]....
View 3 Replies
Aug 18, 2015
[System.Web.Services.WebMethod]
public static string GetChapterDetails()
{
[Code]....
I am trying to get the ID but its giving me null all the time
I am then binding them in my AJAX
View 1 Replies
Sep 24, 2010
I have a url that I want to map routing to:
[URL]
where tabvalue is one of: "personal", "professional", "values" or nothing.
I want to map it to a route like:
Member/Edit/{tab}
But my problem is - I don't know how to specify such constraints. I'm trying this regex:
^[personal|professional|values]{0,1}$
but it only works when I use url
[URL]
[URL]
and doesn't work for
[URL]
how to specify the correct constraint?
P.S. I'm not using MVC, just asp.net WebForms
View 6 Replies
Mar 14, 2011
Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.
My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?
View 2 Replies
Apr 5, 2010
I want to do the following:
routes.MapRoute("testwithoutcontroller", "Overview/Index/{year}", new {year = 2010});
But it fails when I call Overview/Index/2010 and gives me this error:
The RouteData must contain an item named 'controller' with a non-empty string value.
What must I do in order to only have Overview/Index be possible for my route?
View 3 Replies
Jul 11, 2010
When I do an Html.RenderAction( action, controller, new { varName = value } ); if the original request had a parameter equal to varName, then the value is not changed in a render action.
Example:
1. Post to "C1/A1" with a string var _test = "abc"
2. Inside C1/A1 get some data and return a partial view
3. Inside the partial view I invoke an action on another controller. The action has an input variable with the same name and type (string _test) Html.RenderAction( "A2","C2", new {_test="fgh"});
4. the value in _test that arrives at C2/A2 is still "abc"
I've traced through it step by step, and the value used in the view render action call is correct, but in the next trace step, the value received at C2/A2 is incorrect.
If this is not an error, and creating a new route value to pass in render action is not the correct way to handle this, what is?
View 7 Replies
Mar 11, 2011
I'm using ASP.Net 4 URL routing on a web forms site.
I have multiple routes to a single page
routes.MapPageRoute("","our-services", "~/Information.aspx");
routes.MapPageRoute("","our-company", "~/Information.aspx");
On the destination page (Information.aspx) how can I tell which route was used to get there, for example was it from our-services or our-company?
View 2 Replies
May 19, 2010
i'm new to routing in aspnet mvc.. i have following code:
[code]....
when i enter "localhost/school" in addressbar, it is giving 404 error instead it should route to my "schoolIndex" action
i have given route-name as "School" where it is used ?
View 1 Replies
May 3, 2010
How to route url contains # sharp character like this:
~/page.aspx#/Home
to be:
~/Home
View 2 Replies
May 24, 2010
I am an C# ASP.NET developer. I am trying to route URL from one domain to another using Godaddy IIS Virtual dedicated server or Dedicated server for ASP.NET.
For example I have a website application for client_A in my server which is intended to be use by multiple clients with different products.
An example URL: www.myserver.com/client_A/product/bear/?productid=1 or using pretty URL www.myserver.com/A_Application/product/bear/1
I would like to setup for my client to point to client_A using his/her domain.
My Client example URL will be: www.hisserver.com/product/bear/?productid=1 or using pretty URL www.hisserver.com/product/bear/1
View 1 Replies
Feb 27, 2011
I have made an asp.net mvc 3 application with an area called blog. I want to route this area to my subdomain blog.mywebsite.com. How can I achieve this?
How do I need to define my route? Do I have to configure the DNS?
Currently I just use the default area route. I can access my blog area for now at this way.
mywebsite.com/blog
View 1 Replies
Feb 21, 2011
I have a situation where I want a route in my application so that the application's index method can recognize this[URL]The problem is that, when I set up the route corresponding to the first URL, the route for the second URL does not work (even if I set up a separate route for that).
View 2 Replies
Jan 22, 2010
www.yoursite.com/image/http://images.google.com.ph/images/nav_logo7.png
What I need to know here is the Controller Action, and the Global.asax routes
View 4 Replies
Feb 15, 2010
I have added a new route to enable me to have nice seo friendly URLs instead of an id field for some news items I am displaying from a database
My global.asax looks like this
[code]...
The problem I have is that since I have added this extra route all my standard URLS (Home etc) are now displaying the controller and action name after them, for example [URL] is being displayed in the URL for my homepage
The news URLS all look fine they are [URL]
why the Controller/Action is now being displayed on non news URL's and how I can stop this happening, would I use a constraint of some sort on the News route ?
View 3 Replies
Dec 17, 2010
I'm embarrassed to ask this question, but not sure what the syntax is to call a URL from within a controller (not associated with the application).
The reason I need to do this is because I am sharing authentication with another webforms app and would like to clear out the session variables before rerouting to that other URL. I'm just not sure of the syntax to route from an Action method to a URL like www.microsoft.com?
View 2 Replies
Mar 31, 2010
Here is my default route.
context.MapRoute(
"CreditReview",
"Site/{sitecode}/CreditReview/{controller}/{action}/{id}",
new { action = "Index", id = "" }
);
I'm looking to add 'status'. This is what I currently have and it isn't working. I haven't worked with routes.
context.MapRoute(
"CC",
"Site/{sitecode}/CreditReview/{controller}/{status}/{action}/{id}",
new { action = "Index", id = "" });
View 2 Replies
May 7, 2010
I am using asp.net C#/3.5 and stuck.
PHP Code:
Route myroute1 = new Route("{controller}/{action}/{slug}", new MyRouteHandler());
Route myroute2 = new Route("{controller}/{action}", new MyRouteHandler());
Route myroute3 = new Route("{controller}", new MyRouteHandler());
Routes.Add(myroute1);
Routes.Add(myroute2);
Routes.Add(myroute3);
[code]...
View 12 Replies
Jun 6, 2010
is there any way to find out to which route my url is getting mapped in asp.net mvc.
View 2 Replies