Last post Jul 13, 2018 08:06 AM by Edward Z
Jul 09, 2018 05:33 AM|Shailesh S. Ghadge|LINK
I'm working on a old published Razor Project. The Development code is not available. I was able to do some minor edits like add a robots.txt (via adding a rewrite rule in web.config of Views folder) and update meta tags in ~/Views/Shared/_Layout.cshtml
However, when I add a new page, it shows me Resource not found error.
I have tried to:
there is no controller file that I could find. And also no DLL.
Currently, using rules I can display basic html page. But, would rather add a .cshtml in Home. Is that possible?
<rule name="demo" stopProcessing="true">
<match url="demo.html" />
<action type="Rewrite" url="/Content/demo.html" />
<rule name="demo7" stopProcessing="true">
<match url="demo7.html" />
<action type="Rewrite" url="/demo7.html" />
Jul 09, 2018 08:29 AM|Mikesdotnetting|LINK
If this is an MVC application, the controllers will have been compiled into the application's main .dll file in all likelihood. If you want to add new code you really need to get hold of the original source. If that isn't available, you could try using a
decompiler such as JustDecompile (https://www.telerik.com/products/decompiler.aspx) to generate new files from the compiled binaries
Jul 09, 2018 10:13 AM|Shailesh S. Ghadge|LINK
Thank-you for replying.
There is no DLL file in the project. I have added the image of Project Explorer in my question.
Jul 10, 2018 07:52 AM|Edward Z|LINK
I am wondering whether you know original project type.
Based on your current screen shot, it is not Asp.Net Core project. And there is also no Controller Folder or ProjectName.dll in the bin folder. For older MVC project, it will compile the Controller into ProjectName.dll in bin.
I would suggest you give up modifying old project since you do not have source code and start a new project to achieve your requirement.
Jul 11, 2018 04:54 AM|Shailesh S. Ghadge|LINK
Since, all the cshtml files are placed in subfolders in Views folder and they are getting routed somehow, and there is also a Model folder, I thought it might be MVC, Additionally, since it is using cshtml, I thought this is a lite version of Razor Project
hence posted my question here in ASP.NET core sub-forum as the description of the sub-forum included Razor pages..
Is there any way to find how the Routing is happening, because If I simply copy paste a .cshtml page in the Views/Home folder, it is not accessible in the browser. For Instance, If I create a copy of About.cshtml as About2.cshtml, then It will give
Server Error in '/' Application for the URL https://********.com/Home/About2
The _ViewStart.cshtml use the Shared/_Layout.cshtml, which contains the basic Head, Navigation & Footer sections and the middle content is rendered using @RenderBody()
All, cshtml pages in Home folder are using the Shared/_Layout.cshtml
Jul 12, 2018 02:11 AM|Edward Z|LINK
>>Is there any way to find how the Routing is happening
It is impossible to route the request to "About2" if you do not have source code.
The route depends on the Controller action which is defined in the Home Controller file, For Controller files, it need to be compile before using.
To sum up, it is impossible to achieve your requirement without source code, and you need to start a new project to achieve your requirement.
Jul 12, 2018 07:55 AM|Mikesdotnetting|LINK
It's undoubtedly part of an MVC project. And it looks like it is MVC 5 or lower. It is definitely not an ASP.NET Core project. they don't feature a global.asax file. As Edward said, you are missing the most important part, with is the compiled dll file for
the application. If you have access to the hosted version of the application, you should be able to get it from there in a bin folder.
Jul 13, 2018 05:58 AM|Shailesh S. Ghadge|LINK
I'm working on the hosted version of the Application, itself. I downloaded the code after creating a zip from the File Manager via Plesk Panel.
It is a working website. I just need to add a couple of additional cshtml pages.
Currently, as a work around I'm accomplishing this by creating rules in web.config residing in the 'Views' folder, and using plain HTML pages.
Jul 13, 2018 08:06 AM|Edward Z|LINK
>>Currently, as a work around I'm accomplishing this by creating rules in web.config residing in the 'Views' folder, and using plain HTML pages.
It only works for existing Controller Action, and it would not work if you want to add new Action and View to this Controller.