Domanda

I'm new to the whole routing thing in MVC so I'm not sure what to make the title of my question. Basically, we have Google Analytics that pics up stats based on the current url. We added in a referrer to the route so that we can give a link to our partner sites such as:

http://www.mysite.co.za/PartnerSite/home/index

When the user comes to our site directly, ie: http://www.mysite.co.za, I want the url to show "Website" as the referrer.

So in essence,

http://www.mysite.co.za

must change to

http://www.mysite.co.za/Website/Home/Index

My route is current configured as:

routes.MapRoute(
    name: "Search",
    url: "{referer}/{controller}/{action}",
    defaults: new { referer = "Website", controller = "Home", action = "Index" }
);

Can this be done in the routes or should I get my system administrator to update IIS settings and redirect?

È stato utile?

Soluzione

Thanks, So to close this off I needed to have a solution posted. The bottom line is that this is something for IIS, and it does not seem possible using Routes.

Altri suggerimenti

ok,suppose when the user hits the url http://www.mysite.co.za then suppose it accessing Home Controller's Index View Action.Because /Home/Index is the First Default Page in MVC so its not the Part of URL. So for your Case You should write the code like this-

    routes.MapRoute(
          name: "Website",
          url: "/Website/Home/Index",
          defaults: new { controller = "Home", action = "Index" }
      );

Please Try it and let me know the result.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top