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.
Related
I'm having issue deploying ASP.NET MVC app with precompiled views. Until now I was not precompiling views and app has worked for years flawlessly. If I precompile them, the site works on first start just as you'd expect. If I however restart it from IIS, I start getting 404.0 errors. The funny part is: if I change app's non-essential configuration in IIS, IIS restarts app by itself and it comes to life. If it gets recycled or restarted, then it goes back to 404.0s.
I noticed error page describes incorrect physical path. In the screenshot below the physical path is C:\wwwsites\workpal\settings. In fact 'settings' is controller name and is a folder at path: C:\wwwsites\workpal\views\settings which contains index.cshtml. Also, should StaticFile be used here? I'm a newb, but to me it looks like IIS doesn't have a clue how to resolve URLs.
The error
Application is running .NET 4.7.2
IIS 8.5
Application has worked for years without precompiled views, no issues. We used .NET 4.5 earlier, but I doubt it's the reason. I get same results with 4.5.
The only change is turning on precompiled views in VS publish settings. I have tried every 'Advanced Precompile Settings' configuration - same results.
Application with precompiled views works on first start, when IIS detects change in app's directory or when I change non-essential app setting in IIS.
Application doesn't work when recycled or when restarted manually.
I've tried fresh AppPool and fresh Site - to no avail.
Tested on two unrelated servers (physical machines).
I am trying to deploy my MVC application to server with IIS installed on it. I added an application on IIS, published the application via Visual Studio to correct directory, but apparently when I try to run it through my IIS Manager, it gives me an error that the requested URL is way too long and looks strange. It is of form:
http://localhost:80/ClassDeclarations/Account/Login?ReturnUrl=%2FClassDeclarations%2FAccount%2FLogin%3FReturnUrl%3D%252FClassDeclarations%252FAccount%252FLogin%253FReturnUrl%253D%25252FClassDeclarations%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FClassDeclarations%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FClassDeclarations%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FClassDeclarations%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FClassDeclarations%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FClassDeclarations%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FClassDeclarations%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FClassDeclarations%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FClassDeclarations%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FClassDeclarations%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FClassDeclarations%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FClassDeclarations%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FClassDeclarations%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FClassDeclarations%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FClassDeclarations%252525252525252525252525252525252FMyAccount%252525252525252525252525252525252F
And obviously it is not what I would expect. What can I do wrong that this happens? Btw, yes, the project uses Entity Framework.
I have a project with two subprojects. first subproject is the SPA with angularjs and the second subproject is my WebAPI 2. To get the entire project on a production environment (IIS Server) I deployed the first project with depending to the second project (WebAPI) on the IIS.
The SPA starts correctly. But the WebAPI always sends no data.
The request path is: http://localhost:52131/api/persons
But I think localhost is wrong, because the IIS isn't on my local computer. I access on the server with remote access.
The SPA works on the address: kinga-m/myfirstspa
Do I have to deploy the WebAPI separatly on the server or is it enough to set in the project settings that webapi is a dependency?
Currently I've defined in the settings of WebAPI on tab Web -> IIS Express with the project url "http://localhost:52131/" but I think that's wrong.
#Yuro, Basically deploying WebAPI on IIS is not a rocket science. You can have both SPA application & WebAPI application on same IIS server or different, it doesn't matter.
WEB API: Make sure you have created proper 'Application' under Default web site and point web API folder, Along with proper application pool assigned - for correct .NET version. Once this is done, you can test your API directly using fiddler URL something like:
http://localhost/[applicationName]/api/Persons
SPA: You can create another application under default web site and point to SPA web site. Also make sure, you are configuring same URLs into your SPA calls to WEB API. So if above mentioned URL works for you separately, then it will definitely work thru SPA.
Suggestion: always test API calls separately.
Hope you have enabled CORS into your web api, too.
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 have Asp.Net MVC web application. It works fine when I run it on Local IIS or IIS Express.
I deployed it as Azure Web Site. It works fine.
Now I want to deploy application as Azure Cloud Service. I add Azure Cloud Service project to my solution. Then I add Web Role from existing web project.
When I run my solution under Azure Emulator it does not work. I have an error "IIS Express Worker Process has stopped working". In Windows event viewer I have only IIS Crashed error, without any details.
In task manager I have Windows Azure Emulator, but I have no IIS express with my web role.
But when I deploy my solution to azure cloud service, it works like a charm. I'm confused what is wrong. One more point. If I create new web-application in my solution and create web role for new project, then it works fine!
I'm confused what is wrong. Any ideas?
I found the problem. I have this block in my web.config file
<applicationInitialization doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
This cause the IIS Express crashing when web role started.
Hope this helps anybody else.