1

I started working on a project which currently contains a mix of aspx-files and cshtml-files. One of my tasks is to convert aspx to cshtml.

Problem is, that after renaming the file (e.g. Home.aspx to Home.cshtml) the actionmethod "Home" can´t find the file.

So I think there must be a link between actionmethod and file, which is not updated after renaming the file - could that be correct? If so, where can I find it and what can I do to make this work?

Thanks!

adiga
  • 28,937
  • 7
  • 45
  • 66
  • A simple rename of file will not make it a CSHTML, you need to rewrite the entire code – Sunil Dec 28 '17 at 06:23
  • I´m aware of that and I actually did that. But the view can´t be found. – WhoMightThisOneBe Dec 28 '17 at 07:04
  • May be posting a picture of your folder structure will help. – Sunil Dec 28 '17 at 07:11
  • 1
    Update: if I rename the original file, e.g. to Home_old.aspx and rightclick on my folder, choose add razor view and name it Home.cshtml, it works. Now this is some annoying work to do, I am sure there must be a way of just renaming the file and rewrite the code? – WhoMightThisOneBe Dec 28 '17 at 07:16
  • You probably have figured this out by now, but is this problem happening after the file is published or during local testing? – Louise Eggleton Nov 05 '20 at 21:34

1 Answers1

0

Not sure at what point you are encountering this issue, but I had a similar issue when I converted files from aspx to cshtml. In my case everything built fine, but on publishing the files did not deploy. It turned out that in the csproj file, the entries for these pages were were tagged 'None' instead of 'Content' like so:

<None Include="Home.cshtml" />

Instead of

<Content Include="Home.cshtml" />

When an entry is tagged None, it is not included in a publish. I manually changed the entries to "Content" in the csproj, republsihed and everything was fine.

See this answer for more information on build action properties.

Louise Eggleton
  • 807
  • 1
  • 12
  • 24