Issues encountered in deploying ASP. NET 5 applications in IIS

Source: Internet
Author: User
Tags stack trace

A very simple ASP.NET5 program was created with VS2015:

Enter only one line of code in Startup.cs:

 using   System;  using   Microsoft.AspNet.Builder;  using   Microsoft.AspNet.Http;  namespace   hellowaspnet5{ public  class   Startup { public  void   Configure (Iapplicationbuilder app) {app. Run (Context  = context. Response.writeasync ( hello, ASP. NET 5 world!   "        

Change target KRE version to CORECLR:

Press F5 in Visual Studio to run correctly and the results are as follows:

Hello, ASP. 5 world!

Then try to deploy to IIS running in 2 ways: 1) VS2015 publish way; 2) How to manually copy files.

First, the Publish way of VS2015

Published there are 2 folders, one is the AppRoot folder, and the other is the Wwwroot folder:

Point the IIS site to the Wwwroot folder and it will work correctly.

5 world!

Take a look at the contents of the Wwwroot folder:

It's amazing! Just 2 files, one is Web. config, and the other is AspNet.Loader.dll.

Where's the ASP.NET5 program I wrote?

Open Web. config to see:

<Configuration>  <appSettings>    <AddKey= "Kpm-package-path"value=".. \approot\packages " />    <AddKey= "Bootstrapper-version"value= "1.0.0-beta1" />    <AddKey= "Kre-package-path"value=".. \approot\packages " />    <AddKey= "Kre-version"value= "1.0.0-beta1" />    <AddKey= "KRE-CLR"value= "CoreCLR" />    <AddKey= "Kre-app-base"value=".. \approot\src\helloaspnet5 " />  </appSettings></Configuration>

See Kre-app-base, seems to know, into the Approot\src\helloaspnet5 folder a look:

The ASP.NET5 application is here, but not HelloAspNet5.dll (only startup.prof in the bin), but the source code.

Do you deploy the ASP. NET 5 application to deploy the source code together? Does asp.net5 dynamically compile the source code of the entire project at run time? Puzzled, this question aside for the moment.

Looking back at the AppRoot folder, only 2 folders, in addition to the SRC folder just seen, the remaining is the Packages folder:

Do not see, a look startled! Packages even had 55.5m!.

Open up a look, whoa! A lot of bags, a number, there are 64. It appears that everything needed to run the ASP.NET5 application is here (except AspNet.Loader.dll).

A closer look, so many bags of the most dazzling is a super luxury large package--kre-coreclr-amd64.1.0.0-beta1, 50M.

This is also a change to the ASP. NET 5, which packages the runtime environment with the application and does not affect each application.

However, to run a program that only wrote 1 lines of code, even to bring 64 bags, a little justified.

Try the manual deployment below.

Second, try to deploy manually

Based on previous versions of ASP. NET application deployment experience, the Web project must be compiled into a DLL first. However, in VS2015, even if the Web project is successfully compiled, it will not be available in bin.

Later found in the project build setting selected produce outputs on build, you can compile the DLL:

Compiled DLLs can be found in artifacts\bin, such as Artifacts\bin\helloaspnet5\release\aspnetcore50\helloaspnet5.dll (compiled with 162K).

Then a new site is created in IIS, and a bin folder is placed in the site directory, where only one HelloAspNet5.dll file is placed.

The following error occurred while accessing:

HTTP Error 403.14-forbidden

This in turn proves the purpose of AspNet.Loader.dll and copies it into the bin as well. Re-access, still error, but the error message changed:

Couldn ' t determine an appropriate version of KRE to run.

Refer to the first deployment method, via Web. config, to tell Aspnet.loader the required Kre version. Then add the Web. config file, adding the following configuration:

<Configuration>  <appSettings>    <AddKey= "Kre-version"value= "1.0.0-beta1" />    <AddKey= "KRE-CLR"value= "CoreCLR" />  </appSettings></Configuration>

A new error has occurred:

Couldn ' t find package ' kre-coreclr-amd64.1.0.0-beta1 '. Locations probed:e:\aspnet5\websites\packages\kre-coreclr-amd64.1.0.0-beta1e:\aspnet5\packages\ Kre-coreclr-amd64.1.0.0-beta1e:\packages\kre-coreclr-amd64.1.0.0-beta1

Unable to find CORECLR package, it can be seen that aspnet.loader will not be found in the directory of the current Web site, but the root directory has been found from the previous level directory.

This problem to solve, build a packages folder, will kre-coreclr-amd64.1.0.0-beta1 copy over.

New mistakes continue to be made, and this time it is a helpless mistake:

External component have thrown an exception. Description:an unhandled exception occurred during the execution of the current Web request. Review the stack trace for more information about the error and where it is originated in the code. Exception Details:System.Runtime.InteropServices.SEHException:External component have thrown an Exception. Source Error:an Unhandled exception is generated during the execution of the current Web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.   Stack trace:[sehexception (0x80004005): External component have thrown an exception.] System.Web.HttpRuntime.HostingInit (Hostingenvironmentflags hostingflags, PolicyLevel policylevel, Exception   appdomaincreationexception) +361[httpexception (0x80004005): External component have thrown an exception.] System.Web.HttpRuntime.FirstRequestInit (HttpContext context) +541 System.Web.HttpRuntime.EnsureFirstRequestInit ( HttpContext context) +122 System.Web.HttpRuntime.ProcessReQuestnotificationprivate (Iis7workerrequest WR, HttpContext context) +731 

And then... There is no then, yesterday toss a half day did not solve the problem.

And then... I wrote this essay today.

And then... Have an interest in AspNet.Loader.dll ...

"Attached" The current directory structure in the IIS Web site:

Issues encountered in deploying ASP. NET 5 applications in IIS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.