PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] Where i can find my pages cshtml after Deploy in NET 6

 July 13, 2022     .net-6.0, asp.net-core-mvc, web-deployment     No comments   

Issue

I am developing a website in asp.net mvc with NET 6 and when I deploy I cannot find anymore the cshtml pages, but a lot of folders, dll and an .exe.

The problem is that it looks like I need to update all the website each time I modify one single page.

Is there a way to put online only the modified page cshtml without deploying the entire website?


Solution

1. You need add Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package.

2. You also need Copy the cshtml when you deploy.

So my .csproj file like:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
  </ItemGroup>

  <ItemGroup>
    <ViewFiles Include="$(ProjectDir)\Views\**\*.cshtml" />
  </ItemGroup>
  
  <Target Name="CopyViewFilesAfterPublish" AfterTargets="Publish">
    <Copy SourceFiles="@(ViewFiles)"
      DestinationFolder="$(PublishDir)\Views\%(RecursiveDir)"
    />
  </Target>

</Project>

Test Result:

  1. Find cshtml file in publish file.

enter image description here

  1. Test in IIS

enter image description here



Answered By - Jason Pan
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing