开发者

Setting subdomain right for an ASP.net application

开发者 https://www.devze.com 2023-02-25 18:03 出处:网络
I got a hosting with some provider with a domain name e.g. \"domain.com\". I then added a new folder e.g. \"/blog\".

I got a hosting with some provider with a domain name e.g. "domain.com". I then added a new folder e.g. "/blog". Then created a subdomain "blog.domain.com" and made it point to the /blog folder.

After uploading my ASP.net application on the /blog folder, whenever a link is referring to one of the other pages on the site, ASP.net is appending the folder /blog to the URL although it is already the root folder for the subdomain. e.g. Uri="Contact.aspx" will render in html on user side as: "blog.domain.com/blog/contact.aspx". I tried solving it by setting the Uri="/Contact.aspx", this will work but will not work if a user trie开发者_StackOverflow社区d to access the pages through "www.domain.com/blog" and I'd like people to be able to access my site through both ways beside also a separate domain name.

Q1: How to make ASP.net detect the domain/subdomain and act accordingly? Is there some web.config settings for such thing? Or should I do some magic with MapPageRoute? Q2: How possible can both ways be working: "blog.domain.com/contact.aspx" and "blog.domain.com/blog/contact.aspx"??? I thought that one of them should be 404!!


Try with:

    <html>
<head>
<title>Whatever you like</title>
<base href="http://www.blablabla.com">
</head>

Note the "base" clause and where it is placed.

0

精彩评论

暂无评论...
验证码 换一张
取 消