MVC - Add/rewrite Route Data Globally?

Jan 3, 2011

i have quite big ASP.NET MVC 2 application (multiple areas, each with own routing registration) using routes like this :

/Item/12345/Detail - where 12345 is the ID of the item. The whole application just rely on that numeric IDs. But now there is an requirement (seo stuff) to make URLs look like this :

/Item/item-unique-string-name/Detail

I would love to handle this globally in some high level - for example load numeric ID before route evaluation and "replace" it in route data. But i am not sure what is the right spot for such a hack - custom MvcHandler, custom IRouteHandler, somewhere else ?

View 1 Replies


Similar Messages:

Forms Data Controls :: Finding A Textbox Control Which Is In Gridview Globally?

Jul 8, 2010

Globally i want to find a textbox which is in a gridview such that i can use that variable in any of the events.

Is that possible in .cs file or if not how can we retreive the variable of a textbox in to a function after finding the textbox using javascript in .aspx page .I tried to find a control in .cs file but I couldn't get it.

View 3 Replies

MVC :: Webforms Route / Implementing Route In Global.asax

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

MVC :: A Route Named 'Admin_default' Is Already In The Route Collection?

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

WebMatrix :: How To Declare "data" Variable Globally

Apr 1, 2011

I am using the following code:

[Code]....

Now If I put the above code in try catch block, then "data" variable is not accessible outside try block. How I can declare "data" variable globally and then can collect result in it in try block?

View 9 Replies

Route Constraints And Empty Route?

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

Web Forms :: How To Globally Change The Button Css

Jan 20, 2011

how do i globally change the asp button css, that support all browser?

View 3 Replies

Disable View State MAC Globally?

Apr 15, 2010

I'm tired of including

EnableViewStateMac="false"

in every page. How to do that globally?

View 1 Replies

C# - Changing ScriptManager's Attribute Globally?

Mar 30, 2011

In each projects we have several pages which have the following tag

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

Now we would like to change those to (about 80% of Pages)

<asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
</asp:ScriptManager>

Is there any way to do that from a single source like Web.config or Global.asax or using any HTTPHandler.

View 3 Replies

Globally Handling Exceptions In Static Aspx [WebMethods]

Mar 16, 2011

The default behavior of a [WebMethod] attributed static method on an aspx page is to return the error to the caller. We are accessing these methods using json, and the only way we have found of capturing exceptions is either a try/catch in every webmethod on the site or using a javascript callback with the error (which has the unacceptable downside of exposing the error to the client).

Is there any way to globally handle these exceptions using the HealthMonitoring setup in ASP.NET?

View 1 Replies

Globally Changing Format Of Negative Currency Numbers In C#?

Oct 22, 2010

We have a large ASP.NET MVC project where all numbers output to the screen are formatted as currency (i.e. ToString("c"). However, negative numbers are showing up with ()'s. For example:

decimal d = -8.88m;
Console.WriteLine(d.ToString("c"));
//outputs $(8.88)

This is a bit annoying to our users, particularly since there are in textboxes. We have a few thousand places where we send currency fields to the screen like this, so we'd love a way to change the formatting globally. Is there one? All the methods I've seen indicate that you have to create a new formatter, similar to this:

string curCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat =
new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;

We'd prefer not to change all of our ToString("c") methods ... is there a better way? My first thought was to just change our locale to Australia, but realized the date formatting would be screwed up.

View 2 Replies

.net - Globally Overrride MonthNames For All Instances Of A Specific Culture?

Dec 17, 2010

i have this problem where Microsoft actually got the month names wrong for the Greenlandic culture (kl-GL). I also know that i can pass my own array of string to the DateTimeFormatInfo.MonthNames Property, but it seems like the values i specify is only used in the scope of that one CultureInfo instance. Is there a way to tell .Net that every time i have an instance of the kl-GL culture these specific monthnames should be used?

I know that you can create user specific cultures, but i don't have access to some legacy code to actually change the code to use a my own userspecified culture.

View 6 Replies

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

State Management :: How To Apply Session Globally In A Website Using Global.asax File

Jan 4, 2011

how can I implement a Global Session in my ASP.NET 3.5 website in C# using Global.asax file ?

View 18 Replies

Forms Data Controls :: Url Rewrite With Db?

Jan 22, 2011

I've got a sitemap in db with all current url, but some urls has changed so I added a column for old urls so I can redirect if old urls are requested and redirect to the new url.

How can I go about resolving this.

I would like to use 301 status.

UrlRewrite?

View 1 Replies

How To Get The Url To The Current Action (after Modifying Some Route Data)

Aug 17, 2010

I'm localising a site via a Change Language control in the master page. I need to render the control with the current url you're on in each of the different languages.

So if you're on http://site.com/en/Home/About and you change the language to french, I need to direct you to http://site.com/fr/Home/About.

The localisation code works on the route data language property, so I've been trying to figure out how I can:

Get access to the current action (with all original parameters) Get the url to the current action (with all original parameters) with the route data changed.

I've tried passing the ViewContext from the parent into the UserControl, which gives me access to the route data but I can't figure out how to get the language routed url from that.

View 2 Replies

Web Forms :: Getting Route Data For .ascx Codebehind?

Mar 12, 2011

[Code]....

works okey in aspx codebehind. However, how can I get the same parameter value from an ascx file codebehind.

View 2 Replies

Forms Data Controls :: Rewrite Url When The Griedview Page Index Change?

Feb 19, 2010

I want to rewrite url when the griedview page Index change

View 2 Replies

Web Forms :: Can Access The Route Data From The Destination Page

Sep 8, 2010

Looking at the asp.net v4 URL Routing it's easy to see how to access routing data from basically anywhere in the app.

Via: Page.RouteData.Values["blah"]

Unfortuantely the Route data always is blank by the time i hit the page on my v 3.5 implementation of routing. I was wondering if there was any way to either pass the route values to the final page so i can use them there - i really don't want additional logic in my handler file and i have loads of Routes and don't want many RouteHandlers.

View 3 Replies

Data Controls :: Unable To Get Route Data Value

Apr 27, 2016

string query = "SELECT tbl_user.email, myselfprofileClient.clientName, myselfprofileClient.clientImages, myselfprofileClient.CompanyDescription, myselfprofileClient.WebUrl, tbl_user.name,tbl_user.mobileNumber, tbl_user.password, tbl_user.repassword, tbl_user.professions, tbl_user.organisation, tbl_user.webUrl AS Expr1, tbl_user.activated, myselfprofileAddress.MobileNumber AS Expr2, myselfprofileAddress.UserAddress, myselfprofileaboutUs.aboutUs, myselfprofileheader.profile_pic, myselfprofileheader.headerimage, myselfprofileheader.facebookPageLink,

[code]...

There is show error this:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

View 1 Replies

Web Forms :: Is GUID (globally Unique Identifier) Unique

Aug 25, 2010

Is GUID (globally unique identifier) really unique, or it can be duplicate.

System.Guid.NewGuid().ToString()

View 6 Replies

URL Rewrite IIS 2.0?

Jul 1, 2010

I have an URL like that :

/eng/myfolder/mycategory.aspx
I would like to transform it in something like:

index.aspx?FolderId=2&LanguageId=1&CategoryID=12

In a word I want to "write" that,

eng => languageId=2 and myfolder => FolderId=2 and mycategory.....

I don't know if i make myself clear but

with http://mywebsite.com/fr/default

Right Now i have :

<add key = "/en/default" value = "default.aspx?LanguageId=1" />
<add input = " {Rewrite:{REQUEST_URI}}" pattern = "default.aspx?(.+)" />
<action type="rewrite" url="default.aspx?{C:1}" appendQueryString="False" />

But i want Something more global like:

<add key = "/en" value = "LanguageId=1" />
<add input = " {Rewrite:{REQUEST_URI}}" pattern = "(.+)" />
< action type="rewrite" url="default.aspx?{C:1}" appendQueryString="False" />

View 1 Replies

Web Forms :: Rewrite Url In C#?

Mar 11, 2011

Im building a small project.

I have the url : [URL]

View 6 Replies

Rewrite The Url In Forum?

Apr 5, 2010

I have a forum on my website

what i need to do is to rewrite the url :

[URL]

to

[URL] to dogracer players

Is there any quick way to achieve this.

The rewrite should be dynamic because each posts in the forum should have a rewritten url

View 5 Replies

How To Rewrite Url String. In With C#

Mar 3, 2010

how to rewrite url string. in asp.net with c#.net.

View 4 Replies







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