I want to host my ASP.NET 5 project which uses MVC 6 and Entity Framework 7 on Amazon free micro instance.
I can't find any step-by-step manual on how to host ASP.NET 5 projects on IIS, all materials just mention that this is possible but without any guides.
Basically, I'm deploying to local folder and then copying to newly created site, but nothing is working.
Unfortunately, I can't use Azure as it only has one month free trial, not a year.
I'm using Visual Studio 2015 Preview to create ASP.NET 5 projects. I don't think that's difficult to deploy on IIS now.
First publish your website by publishing it as file system in VS 2015 preview, then copy the published folder to your server, create an application in IIS and set the application folder to the wwwroot folder (rather than the root folder), that's all.
Be aware, check if "Microsoft.AspNet.Server.IIS" exists in your website project.json before publishing it.
Edit:
there should be a web.config in wwwroot folder, the content of web.config may be like this (with precompile option when publishing):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta1" />
<add key="kre-package-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta1" />
<add key="kre-clr" value="CoreCLR" />
<add key="kre-app-base" value="..\approot\packages\Rvc.PopUpSite\1.0.0\root" />
</appSettings>
</configuration>
or like this (without precompile option):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta1" />
<add key="kre-package-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta1" />
<add key="kre-clr" value="CoreCLR" />
<add key="kre-app-base" value="..\approot\src\Rvc.PopUpSite" />
</appSettings>
</configuration>
Please notice the value of kre-app-base. Occasionally its value is empty string after publishing in Visual Studio.
I had the same problem with DNX Beta 4.
If someone has the same problem :
You have to target x64 framework (Target DNX Version) when you publish your website in Visual Studio 2015 RC and write "XXX\wwwroot" in Physical Path in your IIS website configuration.
1. First you need to publish the site to the file system:
2. Create a new application in IIS:
3. Unzip the file you've created in step 1 in the website directory from step 2. The folder should look like:
4. You may also need to install DNVM (formerly KVM) and the DNX Runtime Environment (formerly KRE):
Install the DNVM - dotnet version Manager (KVM)
Install the DNX runtime environment inside DNVM (KRE)
You can use the File system publish method. Follow these steps:
1/ Generate in a folder with Visual studio the .dll files
2/ Create a website in IIS manager and give in the path to your folder
I found what I've missed, I need to change url to my public DNS in projct.json file:
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://ec2-54-68-21-4.us-west-2.compute.amazonaws.com/
then after uploading site to Amazon I need to run web.cmd in site root
Related
I am trying to import an ASP.NET project which I know works and I am trying to build it on local. I imported the solution file in Visual Studio and went ahead and did a Clean and Build on it which went ok. Now I am trying to Publish the project and once I do that, I clicked the run button which says IIS Express and I see the following
HTTP Error 403.14 - Forbidden
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
If I was running this application out of IIS Manager, I know how to resolve this by clicking on the project, clicking Directory Browing and clicking Enable but I don't know how to fix this issue if I am running it from inside Visual Studio.
To resolve the issue you could try one of the below ways:
1)Set the below code in the web.config file:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
</system.webServer>
2)Set the default page for your project:
<system.webServer>
<defaultDocument>
<files>
<add value="pagename.aspx" />
</files>
</defaultDocument>
</system.webServer>
if you are using the MVC site then set default routs.
I need to reinstall IIS, and I noticed application requset routing module is not shown in IIS manager. I decided to install in using Web platform installer but inside there it says I have module installed which is true when I go to C:\Program Files\IIS I can see folder "Application Request Routing" there but why IIS can't see it now. Using web platform installer is not possible to uninstall or reinstall module.
It was not easy but important files are: administration.config and applicationHost.config file inside C:\Windows\System32\inetsrv\config
folder. Inside administration.config file, inside moduleProviders section I had to add :
<add name="WebFarmFramework" type="Microsoft.Web.Management.WebFarm.WebFarmModuleProvider, Microsoft.Web.Management.WebFarm, Version=7.1.2.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ApplicationRequestRouting" type="Microsoft.Web.Management.Arr.ArrModuleProvider, Microsoft.Web.Management.Arr, Version=7.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
That made Application request module show in IIS manager. After I opened it showed errors but errors are easy to understand. I needed to make same changes inside application.config file, inside configSection section:
<section name="diskCache" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
<section name="proxy" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
These are changes I made to those files recently but there are probably few other sections I had to add inside application.config file, but idea was to copy those sections from some other computer which has good configuration.
Here is how the deployed content looks like after publishing (on Azure Website):
/approot/packages - NuGet packages
/approot/src - all the source files from the solution
/approot/global.json - a list of global NuGet packages
/wwwroot/bin/AspNet.Loader.dll - the only .dll file in wwwroot folder
/wwwroot/css - front-end code
/wwwroot/lib - front-end code
/wwwroot/web.config - auto-generated
web.config generated during publishing
I'm wondering, how to make it deploy only the compiled output and not the source files?
If you are publishing through VS 2015, then make the following selection to not deploy the source files:
If you are not using VS, then you can use kpm pack command to achieve this. For example, following is the command that VS uses to create the package to deploy (You can enable Detailed logging in Tools | Options | Projects and Solutions | Build and Run, to see this)
"C:\Users\kiranchalla\.kre\packages\kre-clr-x86.1.0.0-beta2-10690\bin\kpm.cmd" pack --runtime KRE-CLR-x86.1.0.0-beta2-10690 --out "C:\Users\kiranchalla\AppData\Local\Temp\AspNetPublish\WebApplication5-91" --wwwroot-out wwwroot --no-source --configuration Release --quiet
Some info:
The effect of the above is that now your application is pre-compiled and you should see a package under the packages folder and the kre-app-base flag in web.config points to this package. Example:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta1" />
<add key="kre-package-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta2-10690" />
<add key="kre-clr" value="CLR" />
<add key="kre-app-base" value="..\approot\packages\WebApplication5\1.0.0\root" />
</appSettings>
</configuration>
I have an host where I hosted a webpage with .cshtml extension. My host is arvixe.com that provides ASP and .NET hosting but when I try to load my web page I get this error message.
Server Error in '/' Application.
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /samples/WoT/Default.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.276
I read something does I have to write something in my web.config file to make it work
like this
<compilation>
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
But I tried everything, paste it in on different lines, nothing worked. What do I miss or do wrong?
I believe you are not making using the MVC feature and trying to load just the razor view outside views or custom Area folders.
Then you need to enable webpages key in Web.config which is disabled by default in .Net 4.0
<add key="webpages:Enabled" value="true" />
<appSettings>
<add key="webpages:Enabled" value="true" />
Repairing this in Windows 10 Pro using IIS 10 was a nightmare, it took two days but I was finally able to achieve the desired results using the following procedure:
Open your web site in Visual Studio. The way you do this is to go to File > New > Web Site and then select ASP.Net Empty Web Site AND before you click OK change the location to your project location. In my case I had my project in C:\inetpub\wwwroot\AspNet\Projects\Test
Open internet information services manager (click the "cortana" search and type IIS, it should show up as long as you have it installed). Locate your project folder under the ServerName > Sites > Default Web Site > ... , right click on it and click the "Convert to web Application" button. Accepting the defaults at the prompt by clicking OK should be sufficient in most cases.
Use the following Web.Config file, or something similar. NuGet may overwrite some settings but this isn't a big problem.
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<appSettings>
<add key="webPages:Version" value="3.0.0"/>
<add key="webpages:Enabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</assemblyBinding>
</runtime>
</configuration>
Delete your bin folder, and packages.config file, if they exist. This is because we must assume that something in that bin folder is corrupt since IIS is designed to run Razor/ASP. In your visual studio project you will need to refresh your project so it knows these files have been deleted. This can be done by clicking the refresh button in the menu on the top of the Solution Explorer frame. In you visual studio project go to Tools > NuGet Package Manager > Package Manager Console and enter the following two commands.
Install-Package Microsoft.AspNet.Razor -Version 3.0.0
Install-Package Microsoft.AspNet.WebPages
This was enough to get *.cshtml pages to be rendered by IIS 10 on Windows 10 Pro.
I have a few appSetting entries in my web.config.
I have some different entries in web.Release.config that I would like to push to IIS(7) when
I publish. (I am publishing using the one-click publish in VS2010 using the web deploy method).
When I publish to IIS and run the app, the app is getting the values from web.config and not web.release.config.
(I am in the Release configuration when I publish).
What am I missing ?
[EDIT]
The app settings section of the web.release.config:
<appSettings>
<add key="StylesheetPath" value="http://mySite/Stylesheet/"/>
<add key="ImagePath" value="http://mySite/Stylesheet/images/"/>
</appSettings>
Thanks
In your web.release.config's appSettings node, add a transform attribute
<appSettings xdt:Transform="Replace">
<add key="StylesheetPath" value="http://mySite/Stylesheet/"/>
<add key="ImagePath" value="http://mySite/Stylesheet/images/"/>
</appSettings>
This xdt:Transform tells the config builder to take the appSettings node in your web.config and replace it with this one. When you deploy it, the web.config should be updated.