1

I'm developing an application for a company that sell some produts and this application is responsable for manage products changes and returns. There are different rules for changes and returns but the "screens/views" are all the same. This application must have a different URLs for each type. for example:

www.company.com/change

www.company.com/return

the application need to have a Login page too.

When I access www.company.com/CHANGE the user is redirected to login page and in this page have a label with change text.

When I access www.company.com/RETURN the user is redirected to login page and in this page have a label with return text.

The question is: How to persist this type through pages, reminding that if the user is inside the authentication area of application and logout, He has to return to the right login page, with correct label text.

I tried to store the type in Session, but if the session over, it's impossible to know how parameter i have to pass to Login page (Change or Return)

I tried too, create a new route in Global.asax like to persist the type, like that:

routes.MapRoute(
    "qwert", // Route name
    "{type}/{controller}/{action}/{id}", // URL with parameters
    new { controller = "Login", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

But this url for example: "xxx/home/list" match and i would like that just

return/abc/abc 

and

change/abc/abc 

to match.

I will persist a record in database with this type, in the end of the process.

How can I solve this situation?

rae1
  • 6,066
  • 4
  • 27
  • 48
Aitiow
  • 882
  • 2
  • 9
  • 18

1 Answers1

1

Question needs a bit of clarification but if I understand correctly, simply treats all links and URLs containing the {type} parameter.

I did a small test and what I got was:

In global.asax:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
      "qwert", // Route name
      "{type}/{controller}/{action}/{id}", // URL with parameters
      new { controller = "Login", action = "Index", type = "", id = UrlParameter.Optional } // Parameter defaults
    );
}

And in LoginController you can get the type like:

public ActionResult Index(string type)
{
    return View();
}

You can create a custom attribute for the session's expiration like described Here and return the user to the appropriate page www.company.com/{type}

Community
  • 1
  • 1
RMalke
  • 4,048
  • 29
  • 42