First, this is not MVC, WebForms only..
I'm using routing to keep my site backwards compatible for our clients, while make my project organized.
I'm also thinking of moving our encrypted query string to a more friendly url. How this works is our clients have to bookmark a huge encrypted url to prevent them from guessing our other clients by changing an id around.
But instead of having this huge url, wanted to add a route like LoginClientName.aspx for each client and have the encrypted query string hard coded or maybe in database.
But don't see a way to add a query to the MapPageRoute..
Was thinking of something like this (know it doesnt work)
routes.MapPageRoute("MapClient1", "LoginClient1.aspx", "Login.aspx?secure=mylongquerystring"); routes.MapPageRoute("MapClient2", "LoginClient2.aspx", "Login.aspx?secure=differentmylongquerystring");
Now this throws exception since it doesn't allow a ? in url.. any ideas how to accomplish this? or is it impossible?
take a look at this:
http://msdn.microsoft.com/en-us/library/cc668177.aspx
basically what its saying is:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
and then:
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("",
"SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx");
routes.MapPageRoute("SalesSummaryRoute",
"SalesReportSummary/{locale}", "~/sales.aspx");
routes.MapPageRoute("SalesDetailRoute",
"SalesReportDetail/{locale}/{year}/{*queryvalues}", "~/sales.aspx",
false);
...
routes.MapPageRoute("ExpenseDetailRoute",
"ExpenseReportDetail/{locale}/{year}/{*queryvalues}", "~/expenses.aspx",
false,
new RouteValueDictionary
{ { "locale", "US" }, { "year", DateTime.Now.Year.ToString() } },
new RouteValueDictionary
{ { "locale", "[a-z]{2}" }, { "year", @"\d{4}" } },
new RouteValueDictionary
{ { "account", "1234" }, { "subaccount", "5678" } });
}
Does this mean that you'd have to specify every route individually for each client? (if Yes, you could have always used web.config urlMapping for this)
Instead, use the client name as part of the route and then use the client name to look up your reallylongquerystring
something like this:
routes.MapPageRoute("ClientLoginRoute","Login/{clientName}","~/forms/login.aspx")
and then on the login.aspx page access the client name etc and look up the long string
String reallyLongQueryString = Magic.GetReallyLongQueryString(Page.RouteData.Values["clientName"]);
Dim reallyLongQueryString as String = Magic.GetReallyLongQueryString(Page.RouteData.Values("clientName"))
I'm presuming here that it doesn't matter if a client knew the name of another client as they wouldn't know the login details (if that makes sense)...as they would still need to enter the credentials etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With