I have just upgraded an app to RC2 and am testing all the hosting scenarios. I'm having trouble figuring out the best practice of how to setup the configuration of each scenario that they would all work.
Here are the scenarios:
1. Local debugging with WebListener (we need Windows Authentication)
2. Local debugging with Kestrel
3. Local debugging with IIS Express (+ Kestrel)
4. Published to IIS
I'm not sure if we need all these, but you know... developers and their preferences :)
So, when you publish the app to IIS, I've set up IIS application physical path to wwwroot-folder. The appsettings.json file is outside the wwwroot so I can load the configuration file using
new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), #"..\"))
This works fine. I have also setup the local self-hosted Kestrel and WebListener working directory to wwwroot so that the same logic applies there.
launchsettings.json
"workingDirectory": "wwwroot",
The problem is now with IIS Express. With IIS Express the current directory is the application root (same where appsettings.json is) so with the current setup, it cannot find the settings file. It seems that I cannot set a working directory for IIS Express(?) and this lead me to think that what is the preferred way to setup this that it would work in all of the mentioned scenarios?
Related
I am attempting to publish our web api to IIS 7.5. I have it deployed as an application "api". I am able to successfully deploy the application and it runs. I can access it at /api/api/. I believe this was due to having "api" in the routing config of the api controllers as well as having it hosted in the "api" application in IIS. I have removed the "api" portion of the route path in web api and it works correctly if I launch it from visual studio. I would like to access it from /api instead of /api/api but IIS doesn't recognize this change. What could be causing this in IIS? I am fairly new to IIS and I have googled around but I have not found anything useful.
TL;DR
I updated routes in my web api application but IIS is not recognizing those changes.How can I force IIS to update?
After playing with this for some time I found that the problem was that I pointing the physical directory of IIS to the deployment package from VS and because I was building the project directly on the machine. This caused VS to quietly fail when it couldn't update the files because they were locked by IIS. After deploying to a new path and then replacing the contents of the application the new routing works as expected.
I made a virtual machine on azure to host my asp.net mvc 5 website. I made a directory in iis on the machine and pointed it to my domain. I first put the default iis.html page and went to it. This works.
Now I put all my asp.net mvc code in that folder and I get "500 server error". I don't know why.
I tried to put in my web config
<customErrors mode="Off">
Yet this did nothing. I don't know why it is failing nor how to check. There is nothing special with this website(just controllers and views...not even a database).
I am not sure if I need to install anything more to get it to work. The vm is windows server 2012.
Follow these steps:
Verify installed MVC version in the server (windows\ assembly folder)
Verify application bin folder which should contain appropriate dll(s) (website/ virtual directory maps to a physical folder, bin should be under the root with required binaries)
Also verify MVC views ('Views' folder should be just under the root)
Verify Web.config, which should be updated properly
Application Pool should be running under appropriate .Net version (Run -> inetmgr -> Application Pool -> Advanced Settings -> .Net Framework Version)
I have a problem with my web application. I develop using VS 2013 (run as Administrator) and Windows 8.
When I debug using IIS Express - everything works fine, without any errors (I run VS as Administrator). When I change project properties to use Local IIS (it's installed) - I cannot use external library which is placed in GAC (Microsoft.FlightSimulator.SimConnect). Also I run VS as Administrator.
Thrown error: "HRESULT E_FAIL has been returned from a call to a COM component" - this says nothing to me. This is thrown during creating new SimConnect object:
var simconnect = new SimConnect(...)
OFC, to use SimConnect, firstly Microsoft Flight Simulator should be launched (and it's started). This was proposed reason of the problem which I found in the Internet - second one was granting permissions (described below).
Details:
I have two projects in solution: library project (which is used to connect to the FSX) and web project (MVC - to present the results).
1) I tried to move whole library project content to the MVC project - nothing.
2) I used IIS manager to publish my website (with the seperate AppPool) - result the same as for Local IIS.
3) I granted permissions to the folder (where projects are placed) for my own AppPool and also for IUSR, IIS_IUSR and DefaultAppPool - full access. And nothing.
4) I ran FSX as Administrator - also nothing :/
I found the workaround: I moved the library project to the another project - console application where I used HttpSelfHostConfiguration to host that. And later, I call this api from the main project (MVC). For this solution everything works fine (I tested for Local IIS [debugging] and also for IIS Manager). I have to only run the Host Api project as Administrator.
I'm very curious what is the reason of the exception. And additionally: how to resolve that :)
It seems like the problem with the permissions - but I granted to the every used AppPool.
Can be the reason lack of permissions for dll in GAC? I don't think so, but I have no idea what to do. If yes, how to grant permissions for dll in GAC (or how to copy that)?
#Krzyrok, Had the same issue recently on my one of my projects where I used external libraries. After following endless crumbs I got it resolved. Change your application pool identity from "ApplicationPoolIdentity" to "LocalSystem". I also changed the sites Anonymous Authentication to "Application pool identity" from the specified IUSR but tested it and it can be left on IUSR. I also granted permissions to the folder for IUSR and IIS_IUSR.
If someone comes across this problem, it is possible that the problem is that you have not configured SSL for your localhost site. The site might be trying to communicate via https port 443 and it cannot find the site there. The site may be hosted only on the unsecure http port. To solve this problem,
Go to IIS Manager
Right Click on the Website
Click on Bindings on the right
Click on Add
Select https
Select the IIS Express certificate
Click OK
I was using the physical path of the \bin folder as the basic settings physical path of the web site in IIS. I forgot I had to publish the web service and use the publish path as the basic settings physical path of the IIS website.
I have developed a restful web service using ASP.NET, and while using the Visual Studio environment, it worked like a charm with IIS Express. The service itself is a complementary feature and will have to run on every machine on which our product is installed.
I have therefore created a new directory webservice, which holds the web.config and the Global.asax file, as well as a directory bin, which holds the RestulWebservice.dll file.
I then have setup a new web page on the IIS, rooting at C:\inetpub\wwwroot. The web page itself is hosting a web application, based in C:\inetpub\wwwroot\RestfulWebservice (which holds the files described above).
However, if I startup the IIS and visit http://localhost:80/RestfulWebservice, all I am getting is an error 403.14, stating that I may not inspect the contents of this folder unless I allow IIS to do so. If I choose to allow this, I am simply presented with the contents of the folder, not the service itself.
If I try to access a resource of the restful web service directly (i.e. http://localhost:80/RestfulWebservice/Home, I get a direct 404.0 error, telling me that the resource does not exist)
What am I doing wrong here, it can impossibly be this hard to get a compiled library ASP.NET web service to run on the IIS, it works like a charm on IIS express.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
I am new to dot net web services and I have created a web service which I was somehow able to deploy to IIS.
Now, I've made some code changes to it and again clicked on "Created Deployment Package". Should I just copy paste these new dlls to the location where my Web service is deployed or is there some-other way to redeploy the code changes for web service to IIS?
Yes simple and easy is copy the dll to iis and you are done, even you may not require deployment package.
in general i publish the site to a local folder and then copy it to server.
but in case you are using local machine iis you can publish directly to respective iis folder.