How to rewrite to a virtual directory with a different application - asp.net

I have a CMS application that manages multiple websites, today whenever i change the codebehind of one of these websites - i have to rebuild the dll for all websites, deploy it - this disconnects all current sessions and is really bad.
The iis is configured to listen to all domain requests, if the request is to one of the websites' domain , the application rewrites it, or example, if someone requests for http://www.example.com, and example.com is configured in the application to be website 12, it is rewritten to http://www.example.com/websites/12/default.aspx.
This is done for all websites.
We want to seperate the dlls of the websites from each other, and from the main CMS, we have a virtual directory to each websites, but when trying to rewrite to it, we discover that IIS support this (we get an "Could not load type '_12._Default'". error).
How can we perform this rewrite so it does rewrite to virtual directories, or if anyone has any other solution for the initial dll seperation problem.
Thanks in advance

You can easly do it with iis7
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

You could use a utility like http://iirf.codeplex.com to achieve this. It's easy to install, improved over past versions, and the owner of the project does respond pretty quickly to questions. Best of all, it's free, and supports global/virtual directory rewriting.
HTH.

Related

Virtual Directory to WordPress blog

I have a website - www.domain.com - with Windows hosting. I don't want to install WordPress on Windows. Instead I want to get a WordPress blog on Linux hosting and create a virtual directory on my main server: www.domain.com/blog - which points to the WordPress blog. However, I can't find how to do this.
I have found documentation on how to create virtual directories in IIS 7.0, but this all seems to involve a directory on the same server.
Thanks, Jon
virtual directories are for running separate applications (different web roots, web.configs etc) on the same server as part of a single domain - so not what your looking for.
As Lex Li tersely pointed out, one option is you can use IIS as a proxy and rewrite the urls to some other host. IIS can modify the urls if nessersary so traffic appears to be served by your Windows server, when in fact IIS is making sneaky requests to the Linux blog behind the scenes and modifying the markup to ensure urls point to the Windows machine, and not the actual url which points to your linux box (your blog could be on any domain/subdomain/path and still appear to be part of yur site).
You could also use a CDN (cloudflare is free for the basic package...) and that allows you to setup rules so you can request content from different origin servers (ie your linux box) based on a prefix (/blog in your case), but all other traffic is sent to your Windows server.
Another option (not quiet what you asked for, but really simple to setup...) - if you can use a sub-domain instead of a prefix to the path (ie blog.domain.com/ instead of www.domain.com/blog) you can just point DNS for blog. to your linux host and www. to your IIS box - no configuration required to your Windows server.
Worth noting that its pretty much always a good idea to use a CDN infront of your web servers, its a layer of protection, makes your pages load faster etc etc etc (and it would work in front of either of the other 2 options suggested above)

Is it secure to put all of your ASP.NET web apps under the same website in IIS (e.g. Default Website)? (more inside)

I am going to need to host multiple websites in IIS, but will not have separate URLs setup in DNS for each one. Because of this, I will not be able to use the Aias/CNAME functionality in IIS to redirect traffic to individual Websites in IIS.
Would it be secure enough to publish all of my web apps to the same Website in IIS?
Example: under Default Website, there is a folder for each individual web app:
-Default Website
--[folder for webapp1]
--[folder for webapp2]
--[folder for webapp3]
URLs used to access each web app:
www.mydomain.com/webapp1
www.mydomain.com/webapp2
www.mydomain.com/webapp3
Is this sort of setup secure or a good idea (best practices)? It seems like a simple solution to the problem of not having a separate domain name in DNS for every web app (website).
What do you think?
I don't see any issue with that approach, in a way it does simplify things quite a bit actually.
Sites being secure is not going to be affected by this. Of course each application would be under it's own pool, it's always a great idea to run like this.
This being said, your main website is going to run under it's own application pool and if there is a problem with it all your applications will be affected. That's the one thing I would pay extra attention to so you might want to not actually use that top level app pool for anything.

ISAPI Rewrite With Azure Web App

I'm not sure if this is the best/correct place for this type of question. But I have an existing .NET website which I am moving from our dedicated EC2 server to an Azure Web App.
However, this current site uses an .htaccess file with about 200 redirects (301 from old urls to new ones) which is powered by ISAPI rewrite (Which was installed manually on the Win2008 server).
I need to keep these redirects, but wondering how everyone else deals with permanent Url redirects on .NET applications when moving to an Azure Web App (From a dedicated server that had ISAPI rewrite installed)?
Putting them all in the web.config seems a little odd to me? And I don't know how that would affect performance?
Any advice or pointers would be appreciated as always.
I always put them in the web.config.
If you think it will be too messy, you can put them in a separate file and use the configSource attribute to link to the file.

How do I add a servlet to an existing website with IIS7 and Tomcat6?

I've configured IIS7 and Tomcat6 successfully with the isapi redirector. I can get my servlets from tomcat's examples, and also my own servlets running from localhost.
http://localhost/examples/servlets/ works fine for the supplied tomcat examples.
How do i add servlets to existing web sites?
I've tried adding a virtual directory to my website, the same way i did for the Default Website, but i get 404 errors
thanks
You shouldn't be adding anything to that directory or root. The proper way to do it is to create your own servlets and package them in a WAR file. That will give your project its own domain/context and keep your servlets separate from others.
Given that, you'll have to tell IIS how to redirect requests for your new context over to Tomcat.
This will work if http://YourSite.com:8080/YourWebApp works. If that doesn't work, you probably have the same problem I was looking to solve.
IIS has an HTTP Redirect module that may do what you're looking for. In the IIS Manager, go to your folder in your existing website that you want to redirect to your Tomcat apps. (Make a new folder if needed.) Look for HTTP Redirect in the features view. It's straightforward after you double-click it. It will redirect browsers anywhere you want, but the new URL will not be hidden or an alias.
If it's not there, you need to install it. If you're using Windows Server 2008, use the Server Manager to add the Role. If it's Windows 7, use "Turn Windows features on or off." It's in one of the folders under IIS.

How to show maintenance page during deployment?

I want to plan a schedule maintenance down time on one of my production asp.net website hosted on IIS windows server 2003.
I think this is the preferred behavior:
All request to http://www.x.com including www.x.com/asb/asd/ will be redirected to a notification page (site is currently down. come back later)
The maintenance will take around an hour. how do I ensure for having this redirection to maintenance page to have the least impact to SEO/google ranking
Preferrably I want to be able to quietly test the production site before it goes back 'live'
Preferrably I dont want to rely on pointing DNS elsewhere.
To make it simple please pretend that I don't have any other hardware in front of the web servers (i.e load balancer, firewall etc)
An idea would be:
to create another app on the same web server
create httpmodule or httphandler to handle any url request and 302 redirect them to the maintenance page
Thanks
Try putting App_Offline.htm to the root directory.
copy an app_offline.htm file to the webroot
http://weblogs.asp.net/scottgu/archive/2005/10/06/426755.aspx

Resources