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)
Related
We are a group of students trying to host our project website in a webhotel, using a test server environment, before we decide to publish it.
However we are having trouble correctly publishing it to this environemnt, and have not been able to get help from the host support.
This is the folder structure for the test environment:
https://puu.sh/sP8Dq/b022c83f34.png
This is the folder structure for our project in Visual Studio:
https://puu.sh/sP8Gb/24e85dfff6.png
When we use FTP to upload our project into the httpdocs folder, along with the web.config, the site remains in the default state.
This is how the ftp server looks like:
https://puu.sh/sP8PE/26e3e45f4a.png
This is a first for us, so any help in how to host our site would be appreciated.
first of all you should be sure that your host provides the necessary tools to host a asp.net mvc application you need to ask this from your host provider, tell them what version of MVC your application is made of, and if its possible to host it there, there are afew issues with lower versions of plesk.
as what you have to do so your website comes up :
you have to copy the whole mvc project into httpdocs folder to view it online.
You need to ensure you are copying your websites 'bin' folder. You may also need to ensure that the MVC assemblies are in it.
When you installed MVC on your local machine several assemblies are registered with the GAC. It may be that your host does not have all the required ASP.NET MVC assemblies installed; if not then you will see a configuration error.
As these assemblies are registered in the GAC, the bin folder will not contain them by default.
Make sure your project explicitly references the following DLLs and make sure the Copy Local property is true.
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
Microsoft.Web.Infrastructure
Rebuild your project and check the bin folder. These files should now be present. Upload the contents of this folder to your host.
Windows 10 Professional
IIS 10
Visual Studio 2015 (Running as Administrator)
I want to run from IIS instead of IIS Express as I have an external IP pointing to my machine and I will be receiving messages from an external source. Ultimately I will be using WebAPI but for testing and setting up IIS I am using a simple ASP.NET MVC 5 Web Application.
I created a new ASP.NET MVC 5 Web Application, this is the skeleton Visual Studio 2015 MVC Template, I then ran the application using IIS Express, no issues:
I then went to IIS 10 and created a new website with "localhost" as the binding:
The Physical Path for this new website in IIS is C:\inetpub\wwwroot\AspNetMvcTest:
I then went to the web application properties and switched to IIS. I was asked if I would like to create a new Virtual Directory:
I clicked Yes, if you click No the operation will be canceled and you unsaved Web Application Properties. You have to click Yes to change to Local IIS Property in Visual Studio.
I then was told that IIS "localhost" was mapped to a different folder and would I like to remap:
I clicked Yes. If you click No you will have unsaved Web Application Property changes again and you will not be using Local IIS in Visual Studio.
This is interesting Visual Studio is trying to change the "Virtual Directory" because it will actual change the Physical Path of the IIS Website not add a Virtual Directory. A Virtual Directory is a folder, somewhere outside of the Physical Path of the IIS website that IIS will treat as is part of the Physical Path folder. But I digress.
Now I am told that the "Virtual Directory" was created successfully:
Now we can look at the changes Visual Studio 2015 made to IIS 10:
We have no Virtual Directories on the website bound to localhost:
My Physical Path has been changed by Visual Studio 2015 and it is mapped to my the directory my simple ASP.NET MVC 5 Web Application resides:
So even though Visual Studio 2015 uses the "Virtual Directory" when changing the ASP.NET MVC 5 Web Application Properties, Visual Studio 2015 was only concerned with the Physical Path and that is the only thing it changed in IIS that I can see.
Now for the Internal Server Error 500 Details
I press F5 in Visual Studio 2015 and F12 Tools says there is an Internal Server 500 Error:
If we inspect the request and response in Fiddler, there 500 Error has a Content Length = 0
To try and get more details of the 500 error I have turned Custom Errors off in my Web.Config and also added httpErrors Detailed and PassThrough:
I added "catch all" exceptions handling to Global.asax, no breakpoint hit:
Here is my Call Stack, which is empty and neither breakpoint in screenshot is ever hit:
I added a Console Application to my solution as "Set As Startup Project" and here is my Call Stack proving a break point can be hit:
Here is a screenshot of Event Viewer -> Application, I cleared the Application log, pressed F5 in Visual Studio 2015, refreshed the Application log and it is empty still:
I thought the issue is folder permissions after Visual Studio changed the Physical Path
So I added IIS_IUSRS and gave Full Control even though the Account does not need that high of a level of permission to the Physical Path directory:
My ApplicationPoolIndentity is Framework v4.0 and ApplicationPoolIdentity The ApplicationPoolIdentity is assigned membership of the Users group as well as the IIS_IUSRS group:
I tried adding the specific Application Pool to the Security properties of ASP.NET MVC app Physical Directory, so first I found the process Visual Studio F5 was attached to:
I added "DefaultAppPool" and my IIS Application Pool "IIS APPPOOL\AspNetMvcTest" to the Physical folder Security.
I added index.html to the Web Application Physical Folder and that does not work:
<html>
<head>
</head>
<body>
<h4 style="color: black">hello world</h4>
</body>
</html>
I have moved the IIS website Physical Path to inetpub/wwwroot back to the directory I created when I created the website, I cannot even browse to a simple HTML file, I get the same empty 500 error
So now I am stuck and do not know what else to do.
TL;DR
Before reading the rest of answer it is likely you just need to run aspnet_regiis which you can do from cmd or via a cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.
Original Answer:
Thanks for all the help from everyone, first thing I should have done was taken a step back and tested an index.html "Hello World" test file from a IIS Website with c:\inetpub\wwwroot as the Physical Path of the IIS website.
When you first install IIS you have a default website, browse to it and make sure that works. Is a great first start to a new machine. But I just deleted that IIS site after installing IIS
Steps I took for fix:
I uninstalled IIS via Control Panel -> Programs and Features ->
Windows Features.
Restarted my computer
Installed IIS for Windows 10 following this document
Tested IIS by creating a Website, using the DefaultAppPool and then browsing localhost, and that worked (again when you first install IIS you have this website but I deleted it on mine a couple days ago)
I Found that my simple ASP.NET Website still did not work though and it was published to c:\inetpub\wwwroot\AspNetMvcTest so it was not a potential folders permission issue. When browsing, instead of loading my ASP.NET Website IIS redirected to the root c:\inetpub\wwwroot and displayed its IIS Welcome page ("iisstart.htm")
This means I needed to run aspnet_regiis, which I did, via cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.
That was it, I was all set, ASP.NET MVC Website started working from IIS immediately upon refreshing my browser (localhost in Location bar).
I think the main problem is that ASP.NET MVC 5 web requires .NET Framework 4.5 at least. From your provided information, the application pool of your web application was using .NET 4.0. It look like you've not registerd ASP.NET 4.5 with your IIS yet.
To register ASP.NET 4.5 with IIS, you could use using Visual Studio's command prompt (as an Administrator), go to the following directory and run the commmand aspnet_regiis.exe -i
C:\Windows\Microsoft.NET\Framework64\v4.5.<version>
After successfully register ASP.NET 4.5 with IIS, change your web application to use .NET 4.5 application pool.
I'm trying to deploy an ASP.NET application to localhost using IIS, I've been reading a LOT of tutorials and following them step by step but I just can't seem to make it work...
I created an Application Pool(TestPool) with .NET version 4.0 and gave it every permission to the folder where the application is at.
I then added an application to the Default Web Site and tried to run it at
http://localhost/TestApplication/
But I keep getting:
Any idea what is wrong and how can I solve this?
Versions:
IIS version: 6.2
OS: Windows 8.1
VS 2013 Ultimate: 12.0
VS .NET: 4.6
PS: It's my first attempt at deploying an ASP.NET application so if you need any further information just leave a comment.
EDIT:
It is now running at least thanks to Julian and Marge, but when I run it using VS it has the default view, why isn't it showing when I run it through IIS? When running through IIS it just lists the files:
This error is because your website, in the IIS Server, does not have the Directory Browsing enabled and the default document (default page of the site ex: Default.aspx) configured.
Go to IIS Server IIS > Default Documents and check if the default page of your site is listed, if no, add the page.
Check the related link:
https://support.microsoft.com/en-us/kb/942062
Generally speaking, you do not need to access IIS manager at all to run your webpage on localhost. All what you need to do is right click on the project and then choose properties. In the Web tab you will find Servers section. Make sure the Project Url is something like http://localhost/myproj or simply http://localhost/ then hit Create Virtual Directory. Your webpage should be up by then, and you can access it either in debug mode, or simply by navigating your browser to the Project Url you have chosen.
When you add web application in IIS ex.
That your hostname should be to add in host file which is C:\Windows\System32\drivers\etc"\hosts
ex.
127.0.0.1 test.pln
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 saved my website in the wwwroot folder. when i am running it through Visaul Studio 2008 it s running absolutely fine with path
http://localhost:3840/GettingUserId/default.aspx
but through IIS it is unable to resolve the images URL , not even the links to other pages r working (Parser Error). The path is
http://bhukrk106154d/GettingUserId/default.aspx
I am using IIS 5.0.
Is there any IIS setting that I am missing out.I have simply copied the same website folder inside the C:\Inetpub\wwwroot folder
I have seen parser errors becasue the website is trying to use an old framework version.
Go to the default website properties in inetmgr -> go to asp.net tab -> make sure that asp.net version 2.0 is selected.
If you can post the error message it will be usefull too.