1

I seek some guidedence here ... ( I'm not sure if this is the best title )

At the moment I prepend a "server name" to the url like this:

server10.example.com

This works fine, except that I need to handle all the subdomains on the IIS and I'm not sure google are happy about jumping around from sub to sub to sub, when it seems the links to the other servers.

I'm kind a hoping for a nice way to archive this wioth asp.net mvc.

Most pages are related to a "server" ... there are however a few info pages, contact, home that dont really need a valid "server" name ... but could just be "na" for not available, but the name need to be maintained, if there is already a selected server, when a user are keeps browsing the site. This needs to be as transparent as possible when I need to create the links to the diffenrent pages.

I could extend the Html Action() extensien to automatically add the selected "server" from the previusly request to the page.

In the format:

/{serverParameter}/{controller}/{action}/{parameterInfo}

And if no server is selected, just add "na" as the {server} placeholder.

I'm not sure if more information is needed, but please let me know if ...

I tired of extracting the selected server from the domain part and the other way also seems better, I just can't think of a good way to structure this ...

Updated

90% of all the pages are about a server that the user select at some point. Could be server10, server9, server20 ... just a name. I want to maintain that information across all pages, after the users has selected it or else I just want it to be f.ex: "empty".

I mostly looking for an easy way of doing this or an alternative ... atm I'm prepending the serverParamter to the url so it ends up being: "serverParameter.example.com".

I want to end up with something like

http://example.com/{server}/{controller}/{action}

instread of

http://{server}.example.com/{controller}/{action}
Syska
  • 1,150
  • 7
  • 26
  • Did you ever find an answer? – DenNukem Nov 14 '12 at 02:44
  • yes @DenNukem, see my own answer below. I also use T4MVC so I have compile time errors when ex changing a controller's actions. – Syska Nov 17 '12 at 22:31
  • Another answer is described here: http://stackoverflow.com/questions/9442494/asp-net-mvc-the-right-way-to-propagate-query-parameter-through-all-actionlinks – DenNukem Nov 20 '12 at 20:31

2 Answers2

0

I went with the already impemented routing in ASP.NET MVC.

{server}/{controller}/{action}

When creating the links it takes the set value for {server} and places the value when generating URL's, so I only need to supply controller and action in the @Html.Action helper method ... this could not have been more easy.

I'm not sure why I did not think about this. One just gotta love routing.

Syska
  • 1,150
  • 7
  • 26
  • Well, this is odd, but... So in my case this route "{controller}/{action}/{id}" does not automatically add "id" at the end, but this route "{controller}/{id}/{action}" works just fine, and "id" does get inserted, without having to specify it explicitly. What nonsense! – DenNukem Nov 20 '12 at 20:57
0

If I understand your question correctly, you just wish to group different collections of content together above the controller/action level. If that's the case, have you considered using ASP.NET MVC areas?

Just right-click on your project, and choose Add -> Area.... Give it a name (what you're calling "server"), and then you can add content, your own controllers, actions, etc. Under this area. You will automatically be able to access it via /AreaName/Controller/Action/etc.

Ethan Brown
  • 26,892
  • 4
  • 80
  • 92