MVC 5.0 500 - Internal server error - c#

I have created an MVC 5 website using Visual Studio 2015 on a Windows Server 2016 Machine.
I build and run the application from VS and it works great.
I published it locally, pointed IIS to the root folder.
The Application Pool is set to .Net CLR Version v4.0.30319.
When I try to access the page on the web, I get a generic error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
There is nothing in the IIS logs.
Not sure how to get this error so I can see it...or if it is a more basic issue. Any ideas on the best way to proceed?

To configure within Microsoft Server 2016, do the following:
Make sure you've installed the feature set for Web Server & Hosting are installed.
If those are installed, create a directory such as: "C:\Program Files\Sample"
Publish your application to the directory
Open Internet Information System
Disable Default Site
Create a New Site
Create a Site Name "Sample" (Take note of the Application Pool Name)
Now link "C:\Program Files\Sample" in Physical Path
For now leave the binding defaulted, this will trigger wildcard
Uncheck Start Website Immediately
Navigate back to "C:\Program Files\Sample" (Accessible through IIS also)
Right-Click and go to Permissions
Choose add new user
Type in "IIS AppPool\Sample"
Choose access your application will require.
Apply those changes, then navigate and start your web-site.
If that doesn't work, you can check the following:
Application Pool:
Sample should of defaulted to integrated and 4.0, if not change it. If your utilizing .Net Core application, you want it to be Unmanaged Code
Programs and Features:
Make sure that you have .Net 3.5, 3.0, 2.0 enabled.
Hostable Web Core & Internet Information System (Under Web Server) for you.
World Wide Web Services Enabled, with the proper Application Development Features.
Dependencies:
You may have to install https://www.microsoft.com/download/details.aspx?id=53840
If you have Core, you'll need: https://aka.ms/dotnetcore-2-windowshosting

Related

How can I run an mvc app on windows server?

I'm really new at this, never hosted an app before, everything I've done so far has been locally.
I have a windows server 2008 sp1 running at work, with IIS installed. I access to it via remote desktop, and I need to be able to deploy my app, first locally on the server, so computers that can access it (through LAN) are able to use it.
Right now, if I create a folder and put some data in it, with an html file, and go to "localhost" in a browser, I can see the rendered html file.
The version installed is IIS 7.0, and my app is uses the MVC pattern, and .net framework 4.6.
If on my windows 10 PC I start my app (vs 2017) I can see it on my browser.
I want to be able to do what I do in my PC but on the server. How can I do this?
Update:
I tried Publishing the app through vs but that is on my windows pc and getting a lot of errors. What I know so far is that a guy from Networks gets the app by the developers and they publish it, but I don't know what kind of files does he need.
I followed tutorials but I just can't apply them.
As I said earlier, I have visual studio installed on my w10 PC, and tried publishing through that app to the ip where the server is, getting a lot of errors.
I don't know what to do, I'm really trying a lot of different things, but I don't even know how the app is supposed to look to be run in any way that is not how I run it in visual studio.
UPDATE:
I'm getting this error when I try to publish locally
Here is the Outline of what we need as per OPs requirement
In VS publish the App to a folder
Sort out the server prerequisites:
Turning Windows Feature On or Off for ASP.NET, ISAPI filters, ISAPI extensions, NET extensibility
Server should have .NetFramework installed
Copy the published folder to the Server
Configure IIS manager to add a new site and set physical path to published folder

Aspnet core 2.1.4 IIS start issues

I made a simple POC in AspNet Core 2.1.2 a few days ago without any issue.
I was able to run it either from IIS Express & local IIS (hosted or started/debugged via Visual Studio).
I updated the project to the latest AspNet Core 2.1.4 yesterday and cannot seem to run any AspNet Core application in my local IIS now.
I created a new project (without https) to be sure the migration wasn't the issue.
About my environment :
Visual Studio 2017 (15.8.4)
IIS 10.0.17134.1
Latest packages downloaded from here (even if already included in the latest VS release) : https://www.microsoft.com/net/download/dotnet-core/2.1
Downloads
Test case :
Created an new "ASP.NET Core Web Application" -> API -> No authentication & no HTTPS
NetCore version 2.1
Once the solution is created, running it directly into IIS Express works.
Selecting the other profile named with the application name also works (starts the console and the service correctly)
I then want to host it in my local IIS :
Add a new website with a custom port (5555) and the physical path set to the solution folder (where sits the bin/obj/program.cs/...)
Once created, browsing the site throws me a "Configuration error" : normal, there is no web.config available.
I then right-clic on my project in VS, select "Properties" and "Debug"
I Create a new profile as such :
Profile
I create a web.config file containing the following (and will be transformed as I change running profile) :
Web.config
The project is not "correctly setup" (correctly as my previous POCs with AspNet Core 2.1.2)
Issues :
If I try to browse the website through IIS, an error 500 occurs
If I try to debug the solution with the "IIS" profile, an error occurs as such :
Startup error
All the HttpFailure*.html files are empty (0kb)
There is no error in the event viewer
There is no error in the IIS log files when enabled
There is no log file when the parameter stdoutLogEnabled is set to true (except when launched via a profile different than the IIS one, but still, no error)
Tests
I tried to :
Restart my computer
Start VS as administrator
Give full permission on the file system where applicable to "Everyone" and the IIS pool user selected
IIS Express & "console" profile still works.
EDIT1 : I also uninstalled everything and tried to revert to 2.1.2 without success (still with the latest VS)
I managed to find what was missing :
In "Windows Features", the following element was not ticked :
"Internet Information Services" -> "World Wide Web Services" -> "Common HTTP Features" -> "Http Errors"
I know it was ticked before installing AspNet Core SDK/bundle, as detailed error pages were served.
Anyway, as soon as this option was enabled again, I was greated with an error stating I cannot override the parameter XXX since it is locked. I had to set it as read/write in the server Feature Delegation.
Then all went good.
I cannot imagine the "Http Errors" was restored to an untick value by installing the SDK/bundle and didn't unticked myself (again, local computer).
I'll put it on the IIS shenanigans tab...

Run a .net project on a system with IIS but no Visual Studio

I have a MVC 5 web application that is working fine. But due to internal security reasons and restrictions of my organization, I cannot host it as a website. My current requirement is to make this app run on a particular computer that has IIS installed on it but no Visual Studio.
My application makes use of MS-SQL database, Entity Framework, C# razors and all other .NET dependencies that are usual in a MVC app, and my target framework is 4.5.1 .
What I Found : I googled a lot, what I got is to create a Virtual Directory using the inetmgr and create the application under that directory. But since already the application is created I cannot go for this fix.
Please help me out by providing some links to refer to or steps to solve this.
Thanks in advance for any help.
What you will need to do is to either:
Use Visual Studio to publish the website directly onto the machine which is hosting the IIS application, as shown here.
Use Visual Studio an publish the application to a folder location on your machine and then use remote desktop or some other method to move the published DLL's to the virtual directory of the application.
Essentially both of them do the same thing, but sometimes due to security reasons, option 2 is easier to accomplish.

Web API 2 get up and running on local IIS

I have Web API 2 C# project which runs fine through visual studio. I type URL to test like this:
http://localhost:51754/api/email/1
It shows me XML file. However when I publish and set up IIS I get
HTTP Error 403.14 - Forbidden.
I am new to this and my question is what kind of configuration I need to have it run on IIS. I am using .NET Framework Version 4.0 Integrated Application Pool to run it.
Probably ASP.NET is not registered within your IIS. Try running the following command from a DOS prompt with elevated user account:
C:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
Obviously you might need to adapt the path to aspnet_regiis.exe depending on your specific OS and version of the framework. Once you have registered ASP.NET 4.0 with IIS make sure that you restart it for changes to take effect:
iisreset

How to run ASP.NET C# web application locally?

For a web application I am using ASP.NET C# (OS- Windows7, .NET 4) and the task has done. But I don't know how to run it locally in Windows7 as well as in Server 2008(.NET 4 and IIS installed in server 2008). And I have to run it in both the platfrom. So any help please. Thanks a lot.
If you have IIS 7 installed on your Win 7 machine, then:
Open you project in VS.NET
Right click on your project's node in solution explorer and choose "Properties"
Switch to the "Web" tab.
Select the radio "Use Local IIS web server"
Click the "Create Virtual Directory" button
That takes care of getting your application to run using IIS. You can also develop/debug ASP.NET applications like this.
As regards, deploying your ASP.NET application, after making sure all pre-requisites are installed. You'll need to use IIS Manager to create a website and associate that website to an application pool.
At first you need .NET 4 Framework on the local computer and you have to add the IIS functionality from Windows 7 corresponding add/remove software (activate functions). I presume you have Windows 7 Pro, because the home / basic edition aren't supporting server / development task like those.
If this tasks already is done, i think you just have to put your files into the iis (standard) inetpub folder (c:\inetpub\wwwroot). You can configure IIS in Windows 7 on mostly the same way as in Windows Server 2008.
Because it appears that you aren't a user of Visual Studio I would also recommend trying Visual Web Developer Express or WebMatrix. Both of those ships with an internal webserver that starts/stops themself while debugging the web application.

Categories