Not sure if what I'm describing is possible, but if so I'd like to know how.
I have an ASP.NET Azure Shared mode website with a domain, lets say mydomain.com pointing to it. I have a shop there, which is currently at mydomain.com/shop.
What I'd like is to point a different domain, myshop.com to the page at mydomain.com/shop. Can I do that?
Probably the quickest approach would be URL-Rewriting, which is installed by default on Azure Website / WebRole.
Configuration can be made in the web.config -> more details although you I would imagine if you're using MVC there might a slightly more elegant Routing method, maybe?
I'm not sure if I get your question right, but
you could use the HttpResponse Redirect from the .net framework in order to redirect the response.
Related
I have an ASP.NET MVC web app running on Azure as generic-site.co. It's a white-label site that supports a number of subdomains: acme.generic-site.co, globex.generic-site.co, initech.generic-site.co, etc. Browsing to each of them changes branding on the pages, but the underlying functionality is exactly the same.
Meanwhile I have an external domain name acme-site.com hosted by GoDaddy. I want to redirect this specifically to the acme.generic-site.co subdomain, but I also want to maintain acme-site.com as the root URL for any further browsing on that site, allowing users to have a pure acme experience without any indication of the underlying generic-site-ness.
I've tried to do this using GoDaddy's Domain Forwarding with masking, but I ran into CSRF issues almost immediately.
Is there any way I can achieve this? I suspect IIS URL rewriting might be helpful, but I'm at a loss as to how to proceed.
Don't use Domain Forwarding with masking.
Just add custom domain acme-site.com to Azure Web App.
And you may need to do one of the following:
Add a middleware or something that change Host in HTTP request header from
acme.generic-site.co to acme-site.com.
Adjust the application to
load correct branding when using domain acme-site.com.
It is probably easier to use IIS Url Rewrite module as you mentioned in your question. There are several examples on how to do this. Please start with this post by Scott Forsyth: https://weblogs.asp.net/owscott/iis-url-rewrite-redirect-multiple-domain-names-to-one
Poorly worded title, but what I want is to do essentially what StackOverflow does when someone types in www.stackoverflow.com: it redirects immediately to stackoverflow.com, eliminating the www. entirely.
Imo, this is the more modern way of doing things: the www. is redundant and (soon to be) archaic. It also breaks an important principle that I want to follow on my web application: that each unique and valid page be accessible by a single url only.
I realize this is a server thing, so I'm expecting the answer to be that the web host needs to take care of this. Since I don't run my own servers, my question is thus: is this possible to do on shared hosting or does one need to be running a dedicated server in order to configure IIS to do this?
The IIS URL Rewriter will allow you to easily set up a canonoical domain rule so all requests are either redirected to www or non www based on your choice. More info on how
Also, several .net shared hosting providers have this module installed so that you can configure this option like you could on your own iis server.
www. is not redundant or archaic if you are using other subdomains. There are issues with cookies that you have to deal with if you set stackoverflow.com as the root domain.
That being said, you would probably want to do something like my answer to a previous question here:
remove 'WWW' in ASP.NET MVC 1.0
Based on the similarities to this question, and based on your tags, I'm voting to close as a duplicate.
Most hosting providers give this for free. The trick itself is usually performed on the DNS level, by introducing a no-hostname A record in your domain.
And this principle of yours is unattainable in principle. At the very least, there's always the URL with IP address instead of name. Then, your server will, most likely, have a private name like server1334.hostingprovider.com, which is also accessible to the world.
In IIS7 using UrlRewrite module I want to do something likes this. I tried everywhere, possibly this is wellknown problem, but couldn't find any usefull solution.
Url "http://tom.mydomain.com" should be read internally as "http://mydomain.com/dashboard?g=tom"
I am using ASP.NET MVC, just in case info is required.
Finally, we have configured our own DNS server to handle this issue. So this question is no longer in my case. However, this seems to be not a good idea to rewrite such url. The Application Request Routing feature in IIS7 is one way to go
I'm currently looking into url-rewriting and how it should be done right and hope you have some inputs here.
At the current stage of development only the kind of url-rewriting I'm interested in is adding facebook like behavior to businesses to which we provide services on our site, i.e. www.mysite.com/ShowBusinessInfo.aspx?id=1 should be rewritten to www.mysite.com/HostedBusinessName. - The idea is that when a business registers on our site they can choose whatever the last part of the url should be.
What would be the best way to support this feature? Custom IHttpModule, Global.asax (I'm afraid that this is too slow?), UrlRewriter.net/UrlRewriting.net or a completely different solution.
The site is developed in asp.net and runs on IIS 7.5.
I've actually done something like this before and this is the article I used as a resource: http://stweet.wordpress.com/2010/03/15/creating-a-new-website-programmatically-on-iis-using-asp-net/
This article will tell you how to programmically add a web site to your IIS using C#. Keep in mind that depending on how your IIS and DNS is setup, you may need to also modify your DNS server. You can find various scripts for doing this here: http://msdn.microsoft.com/en-us/library/ms682129%28VS.85%29.aspx
Hope this helps!
If you have fairly simply rewriting rules, I'd use an IHttpModule that attempts to match the URL's LocalPath property with a value in your DB, and then calls context.RewritePath(string).
If you have more complex stuff, then I'd start looking at UrlRewriting.NET or the routing options in ASP.NET.
This is a follow-up on this question.
I basically have the same question as this question, but with a few differences. First of all, my url is http://site/Image/Cassandra/Image.aspx and I want to see http://site/Image/Cassandra instead. This is a routed page where I use ASP.NET routing to translate an url to the one above. But somehow, it doesn't find my page when I don't add "Image.aspx" or anything else ending with ".asmx".
That annoys me...
Since this has to run on both IIS 6 and 7, and because the administrators won't let me have access to the IIS configuration, I need to solve this from within my web application and I think web.config is the place to add the solution. But what is the solution?
(Btw, I know there is some trick with authentication and a default URL in it but that won't work in this case.)
The problem with the URL you would like to have is that IIS6 would require that a physical resource exist on disk, unless you've configured IIS6 to route all requests through ASP.NET. From your statement this would appear to not be the case.
So, assuming that IIS6 is not routing all requests to the ASP.NET pipeline, then there will be no way of providing the exact URL you are wanting.
I encountered a similar dilemma before and overcame it by modify my routes to include a dummy .aspx extension so that IIS6 would be happy. Is there a reason you couldn't modify your desired URL to contain an extension that IIS6 does route to ASP.NET?