In IIS7, if the default redirect at the website level is a relative path, how to make the default redirect is on https and not http.
Currently if the host is: abc.com and the login page is abc.com/myapp/login.aspx, I set the default redirect (IIS manager -> HTTPRedirect) to /myapp/login.aspx. So, if the user enters abc.com in his browser address bar, he gets redirected to http://abc.com/myapp/login.aspx. I want to make sure the user gets redirected to http*s*://abc.com/myapp/login.aspx.
Would it need a web.config at the root level?
Note that this cannot be done in asp.net code, because the asp.net code is not involved in the processing of this request
Edit:
One way to do it is having a "default" web app i.e. web app deployed at the root (web site) level and then use the standard redirection module available with asp.net. Any thoughts on pros, cons?
Finally we came up with 3 different options:
Use an index.htm at the "Web Site" level and put a javascript that would set the
window.location.href to the https URL.
Use the IIS URL rewrite module
Use a custom asp.net module to do the redirection to a https URL. The dll for this module will be registered in GAC and the module configured at the "Web Site" level. The registration in GAC is necessary because the module will be invoked for the child applications of the "Web Site"
The option 3 was selected based on :
Ease of Deployment. Installing the rewrite module on all the front end servers is more complex than installing a dll in GAC
Support for non-browser User Agents that will not parse the javascript. This eliminates option 1.
Related
I have an ASP.NET application (WebForms) A which serves mycompany.com URL.
I need to host new website (ASP.NET MVC) B on the same IIS, which serves mycompany.com/B/... pattern.
Main objective here is that, we want to keep mycompany.com domain in URL for branding issues.
How can I manage this?
The scenarios I already tried:
I defined mycompany.com/B pattern on load balancer, so that balancer can redirect specific request to my website B. In this scenario, webpage load was successful however resource files such as css, js, etc failed to load because they tried to load from mycompany.com insted of mycompany.com/B.
You can configure B as a virtual directory in A. In IIS manager, right-click on A, choose "Add application.." and configure B from the dialog you get.
Then, the B application will know that it is not a root application, and all helper methods in MVC that generate URLs will add the correct prefix (for example, Url.Action or will give you a url starting with /B/). With methods that take a URL as parameter (like Url.Content), you'll need to use a virtual URL, starting with ~/.
In our IIS server we created 3 websites, so under the folder Sites we have Default Web Site, Site1, Site 2. under Default Web Site we have many many applications and one of these applications called "Main"
Also we have 1 domain name like "http://www.ourdomain.com"
How can I do the following
If the user wrote http://www.ourdomain.com or http://www.ourdomain.com/main, then redirect to Default Web
Site/Main
If the user wrote http://www.ourdomain.com/Site1, then to show the content of Site1 and not an application inside the Default Web Site
If the user wrote http://www.ourdomain.com/Site2, then to show the content of Site2
Our Admin he used the HTTP Redirect and he put the url http://www.ourdomain.com/main so everything is redirecting to main
Also, is it possible to use this configuration site1.ourdomain.com instead of http://www.ourdomain.com/site1 ? and how if yes?
Forgive me for my question, I have no experience about how to work on these things in IIS
Option 1
To get site1.ourdomain.com you just need to set the host header in IIS to use this subdomain. Right click the site in IIS, click "Edit Bindings", either add or edit an existing binding to use the subdomain. I would strongly recommend against having three separate sites in IIS if those sites are subsites.
Option 2
Your other option would be to make the subsites areas in MVC in one project.
I have inherited quite a complex web site project, and when I run it in VS 2012 under the default "Use default Web server" setting for "Server", it serves the login page correctly, under the base URL http://localhost:45632 and I can log in nicely. Then, when I click a menu item with the URL http://localhost:45632/Apps/Visitors/General.aspx, I get a good and plain 404.
If I then create a web site (not application under the default site) for it in IIS 7.5; set the physical directory to the project's source folder; give it a host name, xtjethro.local, and edit my hosts file to point that host name to 127.0.0.1; set the web site project to use a custom server, with a base URL of and finally, browse the site from its context menu, it serves its pages under the base url http://xtjethro.local/ instead of http://localhost:45632, everything works fine.
Then, if I set the web site project to use a custom server with a base URL of http://xtjethro.local, and restart VS2012, running it as administrator, everything works from there as well.
I would like to know why http://localhost:45632/Apps/Visitors/General.aspx doesn't work under VS2012, but http://xtjethro.local/Apps/Visitors/General.aspx does work under IIS.
The Visual Studio development web-server usually runs the site under a virtual directory which matches your project name. That would mean that the URL of your page should be http://localhost:45632/YourProjectName/Apps/Visitors/General.aspx. If you create an application under the default site in IIS, you will probably see the same problem.
You'll need to change the way your links are generated. Instead of using /Apps/..., use ~/Apps/... - ASP.NET will automatically resolve ~/ to the base path of the site.
I'm trying to enable rewrited urls in my project.
it's very good described in this post: urlrewriting by scottgu
It works very well when im running it on localhost, but as soon as i upload it to my host (.net 3.5), it doesn't work! i always get redirected to a 404 page!
Is there a configuration needed to enable this?
as scottgu says no, but i don't find out why it's not working...
thanks
// UPDATE 2.09.2010
Is there actually a way to enable routing or rewriting without having iis7 or the ability to install a modul like ISAPI Rewrite on the server?
Looks like i got a bad asp.net host...
In your localhost environment you are probably running the website on your ASP.NET Development server. That server is set up to capture all request (* . *) and run them through the ASP.NET pipeline.
II6 on the other hand, is configured to only send some requests ( ie *.aspx, *.asmx, *.ashx) through the ASP.NET pipeline. So if you are trying to catch a request for an url like "/my/fine/url" that will never be passed to the ASP.NET handler, and thus not rewritten.
You can change this configuration in the Application configuration for the website:
Open IIS Manager and right-click on the website, choose Properties
On the tab "Home Directory", click "Configuration..." button.
Click "Insert..." button to insert a Wildcard application map.
In "Executable:" insert path to aspnet_isapi.dll, in my case C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll (note: this path may differ on you server).
Remember to uncheck "Verify that file Exists"
Click OK!
And so! All your requests should now be directed to the ASP.NET handler and hence caught in your URL rewriter, regardless of extension.
But I must admit that I'm a bit unsure as to how this will affect performance on you site, routing all requests for static files, css, images etc through the ASP.NET handler. Maybe someone else out there has something to say about that.
/Dennis :-)
There are two ways to get the extensionless routes in IIS6:
a) ISAPI rewrite or other ISAPI url rewriter
b) Use a wildcard mapping to aspnet_isapi.dll
See this blog post for detailed instructions.
Here is example how to use new System.Web.Routing within ASP.NET WebForms.
http://deepumi.wordpress.com/2010/02/27/url-routing-in-asp-net-web-forms/
Ok, wierd problem I cant figure out. Hopefully someone where can. I have inherited a site that was developed with a very over-architected Content Management System. I am having problems now with the redirection functionality built into it.
This is on a dedicated Windows 2003 server running ASP.NET 3.5 sp 1. The redirects are stored in the database, and I have confirmed that the correct redirect is in place in the database. Finally, the file extension .html has been mapped in IIS to the ASP.NET ISAPI. And there is an HttpHandler created to redirect the .html requests. The default documents on the server, in order, are:
default.aspx
index.aspx
default.asp
index.asp
default.html
index.html
for this example, we have two redirects both pointing to the same content page. /example and /example.html
when requesting /example.html it correctly finds the appropriate redirect in the database and does its magic. Bueno. When requesting /example it gives a 404 page. Its not even the asp.net yellowish 404 generic error page. Its the standard vanilla IIS 404 response so it appears that asp.net is not intercepting these requests.
Let me know if any other information is requested and I will try to provide what I can. Thanks in advance for all the great recommendation I am sure will come from the community.
You should be able to map a wildcard extension to go through the ASP.Net ISAPI DLL is the solution.
Installing Wildcard Application Mappings (IIS 6.0) may also be useful.
Without rewriting the CMS, you can put a physical file in a new directory "/example". This will trigger ASP.NET to intercept the request, and hopefully load your page.
If you want to really hack it up you can change the IIS 404 page to be a .NET page in your application that can handle the original request and redirect to the page you really want.
Yes this is correct because /example is not pointing to any file, it is pointing to directory in the web server. Check that Default.aspx/ default.html or any other atleast one of them exists in your app.
If you are using ASP.Net MVC for REST then check your actions are properly written.