URL rewrite rule not working in Visual Studio Development Server - asp.net

How can I troubleshoot url rewrite rules that are not working in my Visual Studio 2010 Development environment?
I am enhancing an existing ASP.NET application.
My issue is the URL rewrite rules written in web.config do not work in my Visual Studio 2010 development environment. It only works after deploying the project to IIS.
I need to debug the project as I am not familiar with how it is designed and developed. It is too big a project.
If rewrite won't work in the Visual Studio Development Server, is there a workaround? I really need to work on the project in debug mode. Every time it takes me to a custom error page.

You can always debug into your local IIS. There are 3 approaches:
You should be able to do this seamlessly if your project is configured to deploy to the local IIS web server - just hit F5. It should deploy then attach.
After you deploy, browse to the local site, then attach to the running site by using "Debug, Attach to Process, w3wp.exe".
Add System.Diagnostics.Debugger.Break() to the line on which you want to break your code, deploy to IIS, then run. A "start debugging" dialog should appear when the line is hit.

URL Rewrite does not work on the built in web server used by Visual Studio. The good news is that you can absolutely debug the site easily using a local install of IIS. See the following blog entry for details on how to do this:
http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx
I would strongly suggest going the route of IIS Express (a quick web search will get you to the download page) that Scott recommends. I tried setting VS up to use my local IIS 7 and struggled with it. When I tried the IIS Express route, I was up and running in minutes with URL Rewrite working nicely in my dev environment - no need to manually attach to anything. After installing IIS Express, I just had to go into the site properties->"Web" tab->"Servers" heading->select "Use Local IIS Web server" and check "Use IIS Express".

If you create an IIS website on your local machine then rewrite should work.
If you don't have IIS installed I think you can download it using the MS Web Platform Installer.
I'm not sure if the debugger will work in this situation, but at least you don't have to deploy to a remote machine to test your changes.

Related

Configure Visual Studio 2013 .sln to use Local IIS (Not Express)

I keep getting errors saying that my IIS express has stopped working and I would like to configure my project to use IIS instead of IIS Express. When I run it I can see that is says IISExpress, as seen in the picture below. I tried to research a possible solution and saw that some people were able to go to properties and change the server to use Local IIS but I don't think I have that option available in the same place because I am using a different type of project. How would I be able to configure my project to use Local IIS (and stop receiving these "IIS Express Server has stopped working" error messages).
Thank you
You need to adjust the project properties to point to IIS.
See: MSDN

How do I change where Visual Studio looks for applicationhost.config?

I've looked all over this site and I cannot find the answer to this question.
Basically I'm trying to set up a new site for use with another project I'm working on. This site will run locally on my personal computer and will also be accessible via internet. So I installed IIS 7.5 Express and IIS Manager 7 to host this site. When I went into VS 2012 elevated to create a new site and map it to 'localhost', it pulled up the following error:
Invalid URI: The hostname could not be parsed.
2nd attempt was by creating the site in a new directory by itself inside inetpub, just for the project itself and leaving wwwroot alone. When I do this, I get the following errors:
Filename:
\?\C:\Users\Joel\Documents\IISExpress\config\applicationHost.config
Error: Cannot read configuration file
File system Web sties are currently configured to use IIS Express. To switch back to using the Visual Studio Development server, change the development server option under the Projects and Solutions\Web Projects category of the Tools\Options menu.
When I browse the above location, applicationHost.config does not exist, but when I go to
C:\Windows\System32\inetsrv\config
I find it just fine. IIS Express 7.5 works fine and IIS Manager can find the default site just fine and will even let me browse it using my web browser. What am I doing wrong and how can I fix this so that VS 2012 can create web sites and access the necessary files.
I run Windows 7 Professional x64 and I just finished installing IIS Express and IIS manager. I configured VS 2012 for Web Development. I ran VS as Administrator (elevated) for all of this.
Okay, I found the solution. I needed to manually set Visual Studio NOT to use IIS. Not sure what the issue is there.
But the solution is here for everyone else having this issue.
It was right there, I'm sure, when I was setting it up initially and I just missed it. After doing that, I could set up the new website to use the file system, which would bypass IIS anyway, but the setting to use IIS was conflicting with the bypass, which caused the error.
Hope this is superhelpful!

How to run an ASP.NET web application without VS2010?

Say, I have an ASP.NET web application that I can run in a web browser by opening that solution in VS 2010 and then by going to Debug -> Start without debugging, or by pressing Ctrl+F5.
I was wondering if it's possible to create a link on my desktop to run the same web app but without starting VS2010 first? (Say, by just double-clicking such link.)
Yes, deploy the site to your local IIS
http://www.codeproject.com/Articles/32210/Deployment-of-a-Website-on-IIS
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/33e0a51a-5f8a-40f2-9923-cdd604e1a812.mspx?mfr=true
Create a windows batch file to start the ASP.NET Web Development Server and point it to your application's root directory.
Here's my .bat file:
"C:\Program Files\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.exe" /path:"E:\NITIN" /vpath:"/MyApp" /port:2510
http://www.codeproject.com/Articles/166319/Run-ASP-NET-Web-Application-from-Command-Prompt
http://www.dotnetperls.com/development-server-bat
Here is a great article describing how to set up your ASP.NET website in IIS. Thus letting it run outside of the visual studio development environment.
You can either upload the website to a hosting server so that the site is accessible from the internet, or you can setup IIS on your development machine and deploy your site to that.
Here is an msdn article with various links on how to go about doing this.
You Want to Run Asp.net Web Site Then U Need To Install IIS 6.0 or Higher in Your Machine..
And want to more guide then Check Out This Link..
https://www.youtube.com/watch?v=aFVcX5W0VEQ

Deploy website from a Windows XP Desktop

On my Windows XP desktop, I have a fairly simple ASP.NET targetting .net 4 in Visual Studio 2010. I can run it on my local host by ctrl + F5, it works all fine.
I have a Windows Server 2003, that I can access via mstsc, but also via Explorer. When I go to the publish section of my build properties, i see 4 publish methods :
Web Deploy, FTP, File System, FPSE
I have already installed IIS 6 successfully on the Windows Server, and given all authorizations for everything I could so far (to get things to work in the first place, will check on that later).
How should I proceed to publish to that remote machine ? Should I target a specific folder ? Do I need to setup things in IIS 6 for that site first ? Or will it all get settled from te properties I have in Visual Studio ?
Thank you guys,
J.
Personally I've always plumped for a manual deployment; that is I create the Web Site in IIS creating an appropriate AppPool and targeting the correct .NET version to utilise. From there simply copy (xcopy if you will) the appropriate files over, e.g. DLL and all supporting pages such as ASPX, CSS and associated images. In most situations where I have direct / RDP access this is what I run with.
That said, this can be automated from Visual Studio and this can be useful for those situations where you're maintaining an awful lot of sites on a regular basis. With IIS 6 and Visual Studio, this was achieved by installing FrontPage Extensions on the server then utilising the Publish option.
For VS2010 it seems this has been streamlined using the IIS Web Deploy module and configuring the Studio to publish in this manner that looks mildly quick...
HTH
I've never used the Web Deploy feature in 2010, so I can't really tell you about its merits or drawbacks. I've read that it works much better with IIS7 than IIS6. If you have direct access to the IIS root folder on the server (typically c:\inetpub\wwwroot) through a network share I would recommend doing the file system deployment. FPSE works as well if you have to publish to the server through a remote URL, but there are some security issues with FPSE that make enabling it on your web server a less than ideal choice.
Once the files have been deployed, all that should be left is to configure the website as an application inside of IIS.
Remote in to the web server and open IIS
Right-click Default Web Site and choose properties (if you've deployed to a subfolder in the root, then locate that folder and choose those properties instead
Switch to the Home Directory tab (Just 'Directory' for a subfolder)
Look for the Application Settings section and click the button that says Create
Optional: Select an app pool if you have created a custom one from the default
That should enable IIS to execute your .aspx files inside of your application. Once you've successfully configured the app for the first time, you can just keep publishing your app to the same location over and over without having to reconfigure it.

How do I prevent my ASP.NET application from constantly restarting in my development environment?

I'm using Visual Studio 2010 and working on an ASP.NET 4.0 web application. At the moment, a co-worker and I are tweaking CSS, which means constantly changing and saving CSS files and then refreshing the running page in a web browser.
Every few saves, the application restarts, causing a considerable delay while we wait for the app to start up, log in again, and return to the page we were working on. In an IIS production environment a CSS file wouldn't go through the ASP.NET ISAPI, but apparently when running with VS2010 and the developent web server this doesn't matter... or something.
Is there any way to prevent this from happening? Thanks!
Instead of using the built in web server in Visual Studio (casinni), you can install IIS on your workstation and specify visual studio to use IIS as the development web server that runs your project. I do this for the same reasons. The Casinni server crashes or fails to start pretty regularly for me.
You could also use IIS7 Express. Not only will the server be faster but it will also be more like your production environment. This should help you iron out any issues before you deploy. Its also not hard to get VS to debug a local IIS instance.

Resources