Url with email address in ASP.NET MVC4 -


i have situation i'm using urls possibly contain email addresses. example:

http://myurl.com/edit/mike

or

http://myurl.com/edit/bob@whatever.com

according this stackoverflow question appears easy way around use querystring instead. there way set in routing rule, determine if value invalid , have fall querystring?

how this:

route:

routes.maproute(     name: "useredit",     url: "edit/{user}",     defaults: new { controller = "user", action = "edit" },     constraints: new { user = @"[a-z0-9]+" /*add valid characters here*/ } );  routes.maproute(     name: "usereditwithillegalchars",     url: "edit/",     defaults: new { controller = "user", action = "edit" } ); 

the route match urls /edit/mike , edit/?user=bob@whatever.com.

generating url works. example

@html.actionlink("1", "edit", "user", new { user = "mike" }, new { }) @html.actionlink("2", "edit", "user", new { user = "bob@whatever.com" }, new { }) 

produces same urls above

controller:

public actionresult edit(string user) 

note: 1) need check if user null 2) add valid characters constraint because don't know of them.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -