How do I get environment variables to persist on IIS after running Web Deploy? - asp.net

I have an ASP.NET Core web site that I'm deploying to a VM running IIS on Windows Server 2019. (It's on Azure, but I don't think that that really matters here.) There are some settings that I've configured as environment variables in the IIS Manager. It works fine, but when I deploy a new version using Web Deploy from Visual Studio, the settings get wiped out and the site breaks until I go back into IIS Manager and set them again. Is there a way to set IIS environment variables on the server so that the won't get erased when I deploy a new version? I'd prefer not to use appsettings.json because I don't want the values checked into my Git repository.

Related

Unable to run migrated web application in VS2013

I have an ASP.Net web application developed in Visual Studio 2008 (.Net 3.5). I have copied this solution to another root folder (both on my Win7 64b machine) and upgraded the copy to VS2013 (Professional) and .Net451, but when I try to debug the web app in VS2013 I get an Access Denied error ("Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server"). I don't have this issue runing the original from VS2008 on the same machine.
Apart from the changes mentioned above the two are a straight code copy.
In VS2008 the project Web properties are: Use Visual Studio Development Server, auto-assign port, Virtual path = /
In VS2013 the project Web properties are: Server=IIS Express, Project URL=http://localhost:63064/ (and I have clicked on Create Virtual Directory)
I can see this must be some sort of security issue, but what extra needs to be done to get a VS2008 web app, upgraded to VS2013, to run within the VS2013 IDE?
Postscript: If I start the web app without debugging (ctrl-F5) I get "HTTP Error 503. The service is unavailable."
It turns out that the simple solution is configure the web app properties in VS2013 to use the local webserver (IIS) instead of IISExpress, and also to run VS2013 as administrator (but this is not necessary for VS2008). So obviously it is an IIS permissions thing but IIS is common and hasn't been changed - so what has changed in VS2013 to make this necessary? I don't really want to run VS2013 as administrator if I can avoid that.

Missing Web Management Service on IIS (WIN8)

I have seen this asked here before, but none of the other posts solved my issue, so here goes nothing.
We are attempting to use Web Deploy on IIS to automatically deploy our application to a test environment. The idea, besides bettering our deployment process, is to allow Jenkins to deploy our application to IIS and run a few automated tests.
For this we are attempting to use MSBuild along with a deployment profile on our web app. The IIS lies on a Win8 virtual machine, where we try to run MSBuild and it fails because the Web Management Service is not up, and it doesn't show anywhere on the IIS management software.
I have the Web Deploy feature installed, as I have seen from Web Platform Installer, but the Web Management Service icon is nowhere to be found. I have found and started the service manually on the Windows Services configuration, but that doesn't seem to have helped either.
A few other observations:
"IIS: Management Services" item doesn't seem to show up on my Web Platform Installer;
I tried changing my installation (under Windows' Add an remove programs) to include web management, id didn't help
I enabled IIS' Web Management on Windows' "Add and remove features" settings. Also nothing shows up on my manager.
My Windows language is set to Portuguese. I may have missed the config due to bad translation, but that's unlikely.
So, how do I get the service to run so I can configure it on my IIS and finally deploy my application?
Client OSs doesn't come with Web Management Service. You cannot set up remote publishing using Web Deploy for a site that is hosted in IIS on Windows 8.0 or 8.1. You need server OS for same.

ASP.NET and IIS 7.5: Creating a virtual directory

I have written an ASP.NET MVC 5 application in Visual Studio 2012, and I am now attempting to run it on IIS 7.5. Following a tutorial, within IIS Manager I have created a virtual directory, whose physical address is the address on my computer of the web application. That seems to work fine.
However, the tutorial also says that an alternative way to create this virtual directory is from within Visual Studio. Again following the tutorial, under the project Properties->Web, I select Use Local IIS Web server, and then type in http://localhost:8010/MyWebApp as the Project Url. Then, after clicking the Create Virtual Directory button, I receive the message The virtual directory was created successfully.
However, I notice that this virtual directory does not appear in fact appear in IIS Manager, even after refreshing or restarting. What am I doing wrong? (Note that Use IIS Express is checked, if that makes any difference.)
Using IIS express is the issue, the IIS manager is for the inbuilt IIS instead.
If you untick that use IIS express box, it will remove the port number and you will create a virtual directory under the main IIS installed.
http://localhost/MyWebApp
Note that VS must be run as an administrator for it to be able to access the IIS metabase, otherwise your web app project will fail to load.
If you are running on a base install, you may also need to install some extra features into IIS to get it working properly.

Octopus Deploy not updating web site

I am using octopus deploy to push my website into environments
the code gets to the server but octopus doesn't change the web application to point to the new directory.
e.g.
MVC4WebSite is a web application mapped to the C:\Sites\dev\MVC4WebSite\1.0.0.0
I deploy my package
the new code appears at C:\Sites\dev\MVC4WebSite\1.0.0.1
I expect that MVC4WebSite would be mapped to the C:\Sites\dev\MVC4WebSite\1.0.0.1 but it is still mapped to C:\Sites\dev\MVC4WebSite\1.0.0.0
I get this message in the logs.
'Could not find an IIS website or virtual directory named 'MVC4WebSite' on the local machine. If you expected Octopus to update this for you, you should create the site and/or virtual directory manually. Otherwise you can ignore this message.'
I have definitely created that site (as a web application).
Specs
Win Server 2008 r2
IIS7
Octopus Version 1.0.30.1340
Ok it looks like I didn't interpret the instructions properly.
I interpreted the term site as being any code deployed as a Virtual Directory or a Web Application...what they mean, correctly, is the actual site eg. "Default Web Site"
I needed to define a custom variable to override the OctopusWebSiteName pre-defined variable with the value "Default Web Site/MVC4WebSite".
What a waste of an afternoon :(

URL rewrite rule not working in Visual Studio Development Server

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.

Resources