MVC Custom Routing Long Custom Route Not Clicking In Head?

Jun 5, 2010

I have spent several hours today reading up on doing Custom Routing in ASP.NET MVC. I can understand how to do any type of custom route if it expands from or is similar/smaller than the Default Route. However, I am trying figure out how to do a route similar to:

/Language/{LanguageID}/Question/{QuestionID}/

And what I would like, too, is similar to how SO works. Something like:

/Language/{LanguageID}/Arabic/Question/{QuestionID}/Some-Question-Title

Where "Arabic" and "Some-Question-Title" can be almost anything because what really matters is the ID's

A complete url example might be

[URL]

Am I going beyond what can be done with the extended URL past the language ID?

View 1 Replies


Similar Messages:

C# - MVC 3 Custom Route Handler - Skip To Next Custom Route Rule?

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

Custom Server Controls :: Add Script Tag Within Head Tag In ServerControl?

Nov 7, 2010

I'm gonna use JQuery files in my custom ServerControl , So I inserted jquery-1.4.3.min.js file into the Solution in JavaScriptFiles Folder. Now, I have to add below line within Head tag whenever a user use this ServerControl.

<script type="text/javascript" src="JavaScriptFiles/jquery-1.4.3.min.js"></script>

How can I do it in ServerControl with C#

View 4 Replies

Custom Control Render JavaScript Code In Head Tags?

Feb 3, 2011

I am creating a custom control and was wondering if it is possible to render any JavaScript in the head tags of the page it is placed on? I am thinking I would need to use the FindControl method, but am not sure what I need to bind to. I am thinking the page object? Let me know if I am thinking in the right direction or if there is another option.

My only concern with the above mentioned idea is that how do I render all my content while placing some code in the head tags?

View 2 Replies

How Will You Do This In MVC Custom Route

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

MVC :: How To Add A Custom Route

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

Use Custom Route With RedirectToAction (asp.net Mvc)

Mar 8, 2011

I use the RedirectToAction with parameters in my action method

return RedirectToAction("ListThreads", "View", new { category = "1", subcategory = "49"});
After redirect the url comes out like this
http://domain/Forum/View/ListThreads?category=1&subcategory=49
I want it to be generated like
http://domain/Forum/View/ListThreads/1/49

How to do it?

Note : I already have a route in global.asax that is used by all the pages/links.

context.MapRoute(
"Forum_subcategory",
"Forum/{controller}/{action}/{category}/{subcategory}",
new { controller = "View", action = "ListThreads", category = "", subcategory = "" }
);

View 1 Replies

MVC Custom Route Fallback?

Jun 5, 2010

I'm wondering if it is possibile to customize routing in a way that all requests are evaluated by a piece of code, redirected to the relevant controller if a match is found or passed to next rout in list if not found.

sample request:
/my coolpage/another one

the code searches and determine that the right controller for this is Page, action is "list" and id is "123" and so redirects

another request:
/products/list/5

code finds no match al passes it back to next route that knows how to handle it...

View 1 Replies

Custom Route With More Than One Parameter In Url (customer - Extra Info)

Jan 31, 2011

I have a multi tenant system and I need to allow administrators to edit the information of other customers. I believe the correct way to do this is to append the customer ID to each request, and update my routes accordingly. How do I make ASP.NET accept and use something like this in the controller (order doesn't mean much to me): [URL] and how would I pass and consume that in my controller? The ASP.NET tutorials skip this... (or I don't know where to search)

View 1 Replies

MVC :: Custom Route Returns 404 When All Optional Parameters Are Null?

Feb 19, 2010

I get a 404 error when I navigate to the following URL using the route below:

http://localhost:53999/properties/

However, all the following are correctly routed to the List action in my controller:

http://localhost:53999/properties/usa/new-york/manhattan/12

http://localhost:53999/properties/usa/new-york/manhattan

http://localhost:53999/properties/usa/new-york

http://localhost:53999/properties/usa [Code]....

In PropertiesController.cs: [Code]....

It looks like it should just go to the default controller/action,

View 5 Replies

C# - Custom MVC Route: Changing Where The Views For A Controller Are Located

Jan 5, 2011

So I have a controller called EmployeeController, and all the Views are in /Employee.

I'd like to create a route so that the EmployeeController will use /Employees and /Employees/Add instead of /Employee and /Employee/Add.

I keep finding articles about how to change the route to go to different actions.

View 3 Replies

MVC :: Synonyms For Controllers (Custom Routing)?

Jul 18, 2010

I have an ASP.NET 4 MVC2 multi-language application and I need the same HomeController to response ДОМОЙ as well.Our application has 12 Controllers and should support 9 different languages.The optimal solution would be to override some FindControllerByName & FindViewByName, but I can't find such functions.
Do any of you guys know how can I achieve such a behavior?

View 4 Replies

Web Forms :: Pass Custom Data Through URL Routing?

May 29, 2012

I use url routing according to this article [URL]

this is global.asax code

void Application_Start(object sender, EventArgs e) {
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes) {
routes.Add("BikeSaleRoute", new Route (
"bikes/sale",
new CustomRouteHandler("~/Details.aspx")
));


here when we type eg:[URL]  it go to details.aspx  now i want instead of bikes/sale that define here it read Behcode column from DB and when my user type their becode like this   [URL]  it go to details.aspx 

how i can do it?

this is my users table

Id Behcode name description

1 1111 Jack Test
2 2222 Sara test

View 1 Replies

Configuration :: Web Form Routing And 404 Custom Error Page?

Jan 28, 2011

I have a problem with my site, and I'm using .net 4, web form routing

I have this route ,routes.MapPageRoute("JobPreview", "jobs/{jobId}/{pg}/{Position}", "~/default.aspx")

so, this page is working fine
http://www.jobsagents.com/jobs/24651/1/automation-qa-engineer

If we remove the last segment of this url, it should be redirected to the custom 404 not found page, but in the deployment server it redirects to the default IIS error page for 404 errors

http://www.jobsagents.com/jobs/24651/1/, on my local machine it's ok, and shows my custom error page.

If we remove the last three segments of the url
http://www.jobsagents.com/jobs it works fine on the deployment server.

View 1 Replies

How To Implement Custom 404 Page In .NET Web Form Application Using Routing

Jun 19, 2010

I am using ASP.NET 4.0 Web Forms. I learned that, in order to optimize my Web Application for Search Engine, I must implement custom 404 page. But the way Microsoft tell us to implement custom 404 (within Web.Config file), that is not good for SEO. Microsoft says,

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="404" redirect="Page-Not-Found.aspx" />
</customErrors>

But when the page is not found, IIS issue 302 redirect to Page-Not-Found.aspx page which is not good. So, I implemented custom 404 page using Routing technique that is available in ASP.NET 3.5 SP1 and 4.0. I used the following router in Global.asax page

View 2 Replies

.NET MVC2 Custom Routing With Wildcard Or Free Text Url?

Sep 28, 2010

I have a requirement to add specific functionality to an asp.net mvc2 web site to provide addtional SEO capability, as follows:

The incoming URL is plain text, perhaps a containing a sentence as follows

"http://somesite.com/welcome-to-our-web-site" or "http://somesite.com/cool things/check-out-this-awesome-video"

In the MVC pipeline, I would like to take this URL, strip off the website name, look up the remaining portion in a database table and call an appropriate controller/view based on the content of the data in the table. All controllers will simply take a single parameter bieng the unique id from the lookup table. A different controller may be used depnding on different urls, but this must be derieved from the database.

If the url cannot be resolved a 404 error needs to be provided, if the url is found but obsolete then a 302 redirect needs to be provided.Where the url is resolved it must be retained in the browser address bar.

I have had a look at the routing model, and custom routing and can't quite work out how to do it using these, as the controller would not be predefined, based on a simple route. I am also unsure of what to do to provide 404, 302 back to the headers also.Perhpas I need a custom httpmodule or similar but going there went beyond my understanding.

View 5 Replies

Custom Server Controls :: Custom Tag Not Found For Control / Error: Unknown Server Tag 'custom:AjaxValidator'

Jan 3, 2011

Hope this is the correct forum for this question. I am using VWD 2010 an have a web project and get the following error upon execution:

Parser Error Message: Unknown server tag 'custom:AjaxValidator'.

My code is as follows in the .cs file:

[Code]....
[Code]....

View 1 Replies

Custom Server Controls :: Custom Composite Control With Custom Templated Child Controls?

Mar 22, 2011

I am trying to build a custom composite control, which allows me to add custom content to each child control. It's a similar concept to what you have with a GridView and TemplateColumn. The markup used to place the control on the page would end up being something like this:

[Code]....

I have the code below, which allows me to put that markup on the page without throwing any errors, and it renders all the correct HTML, except it doesn't render the contents of the ColumnTemplate. I have replaced the Render() code with a comment because it's quite long winded and doesn't add anything important here:

[Code]....

I have tried to follow examples on MSDN and other forums but I can't make this work. I think I'm missing the code to render the contents of the template, but I don't know how to hook that up.

View 1 Replies

Custom Server Controls :: How To Create Custom Property (DataSource) In Custom Controls

May 15, 2010

I know that how to create custom control and add custom property.

I want to create property like DataSource to my custom control.

View 1 Replies

Where To Use Route-name Of Routing In Mvc

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

MVC :: MVC Routing Options A Single Route?

Jul 30, 2010

I am building a forum based application and was wondering if I had to create a different route for each of the following scenarios: View Forums, View Topics, View Posts, Reply to Topic etc... Is there a single route that I can customize to catch all of these for the folllowing urls?

http://www.samplesite.com/forums

http://www.samplesite.com/forums/{forumID}

http://www.samplesite.com/forums/{forumID}/{topicID}

[code]...

Is there a custom route I can make to catch all of these instead of making a different route for each one?

View 1 Replies

Web Forms :: Wrong Route Gets Selected In URL Routing?

Feb 18, 2011

I am building an application in Asp.Net 4.0 (Web Forms). I have used the feature of Routing introduced in this version of Asp.Net (4.0).

I have a few routes declared in my global.asax file. My problem is as long as the number of parameters (placeholders) declared in the route are different the right route is selected. But the moment the number of parameters (placeholders) declared in the route are same there is a clash and the Routing engine selects the wrong route. The only way I found was to use a Constant with one of the clashing routes to distinguish between the two. But I am sure there is a way out of it; I also tried using Regular Expression but still it selects the wrong route.

[Code]....

The last two routes have the same number of parameters so I tried to separate the second last route by adding a regular expression, but in vain.

View 19 Replies

Mvc Routing - Ignore Route With Extension In The Middle Of URL

Sep 6, 2010

i How can make the asp.net routing engine ignore routes with an extension of the type /pathtofile/filename.aspx/morepaths

I know this is hardly a real scenario but I need to know for another similar issue for an autogenerated url

View 1 Replies

.net MVC Routing - Preventing A Route To An XML File With A Constraint?

Feb 8, 2011

I'm attempting to find a way to preventing a user from accessing a specific xml file. I've tried doing...

route "SiteMap",
"SiteMap/siteMap.xml",
new { },
new { isLocal = new LocalHostRouteConstraint() });
[code]...

View 1 Replies

MVC :: Routing Error On Default Route In Virtual Directory?

Feb 17, 2010

I have an application that I run in several places (demo, production, local, etc.) that all use different virtual directories for the placement of the MVC application.

I use StructureMap in this application, so I am overriding the ControllerFactory to use StructureMap to build controllers (when the passed controller instance is not null).

My problem is that the controller instance being passed to the controller factory IS null, which is fine if said route didn't exist, but it does... specifically, it should be my DEFAULT ROOT route.

Basically if I host the app at [URL], everything works fine except when I have a '/' on the end of the URL (meaning,[URL]... the latter works fine, while the former gives me the error). It looks like when that slash is there, the routing engine is deciding that it should be looking for a controller named MvcController, which doesn't exist, and which then passes the null controller instance to the ControllerFactory, resulting in the following error:

The controller for path '/Mvc/' could not be found or it does not implement IController.
My Default route is the standard default route. Removing all other routes has no effect. My default controller is HomeController.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved