0

I am working on site which is scattered in multiple subdomains. From the main site I have to create url which points to sudomains. How can I do this.

for example, my main site is www.mysite.com I need to create a url pointing to blog.mysite.com/userId/Name which will point to HomeController and Index method witch userId and name.

Also, how should I handle the urls on local machine as well on the production machine.

Help will be appreciated

updating my question here.

What does

@Html.ActionLink("MyLink","Index","Profile","","www.test.com",null,null,null)

do.

It creates a link, but with port number in it. If there is anyway I can avoid it.

Regards

Parminder

3
  • do you want these sites to actually "own" their own application? Or do you want it just to appear as they do? (ie can they share cache, session etc?). Having them appear as they do, might be rather easy-- could probably be done with Areas. Commented Nov 13, 2011 at 21:31
  • yes, those sites will be totally different. will have their own application, controller, actions and everything. Commented Nov 13, 2011 at 22:01
  • agree with the response by @Saintedlama. Seems like this question is really independent of mvc. As you would with any IIS hosted site-- you're going to have to set up each site separately in IIS. I don't know how many sites you are creating-- but this can be a bit of pain IMHO. With areas, each "site" could have it's own controller and actions-- but they are going to share Session, Cache etc. Commented Nov 13, 2011 at 23:42

3 Answers 3

2

As your sub domains will host their own applications with controller and actions I'd recommend to use the good old HTML hyperlink to create that link:

<a href="blog.mysite.com/userId/Name">Your Blog</a>

Why: Because you do not want to couple your disjoint applications and ASP.NET MVC does not have a clue (and should not have a clue) about the routes used in some other application. For constructing the link you can add an extension method to HtmlHelper to avoid typos and URL path encoding quirks.

Sign up to request clarification or add additional context in comments.

1 Comment

At the end of the day, this is definitely there. But I was looking if Asp.net mvc has something to offer.
0

Regarding port number-- you really need to set up a virtual directory in IIS to avoid it. And if you're goal is to have separate sites-- you're going to have to set up virtual directories for all the subsites as well. I am wondering if you really need to set up completely separate sites? How extensive will the subsites be? Will there be any connection between the "root" site and the "sub sites".

Out of curiosity--- how many subsites? If you can do it without revealing too much-- what is the end goal here?

3 Comments

Thanks ek_ny, you can post many types of content(pics, blogs, photos) which can be accessed in differnt sub domains then.
Parminder-- I'm not sure you need separate applications-- I think you can get away with one application-- btw-- the subdomain should never be an issue in development because you're never hardcoding it.
ek_ny, its long story. Yes, I need to set it up the sites separately, I feel its easy to maintain broken part than compiling the whole application as it gona get bigger day by day. I am building something similar to socialengine.net, where people can add new module to it. Setting it up at iis works.
0

If you are looking for string typed items you might want to use the razor @helper syntax.

You could create @helper.blogLink("Title", "Action", "Controller") that creates a link to the subdomain.

http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.