Hatef.
Hatef.

Reputation: 544

ASP.NET Core exception "View was not found"

I created a solution with multiple applications and I configure routes like this :

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "ControlPanel",
                template: "ControlPanel/{controller=Home}/{action=Index}/{id?}");

            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

I can navigate to ControlPanel project and it goes into ihome controller in but i shows this error : enter image description here

I find out that it sets base directory in my program.cs when project runs first time and it is my main webapplication assembly name (CustomerProject) :

enter image description here

so now how can I change ContentDirectory and wwwroot directory to new assembly name?

Upvotes: 0

Views: 556

Answers (1)

ivamax9
ivamax9

Reputation: 2629

I guess you went to URL has controller name without specifying action method or it was smth like this yourhost/iHome/Index, so as for result you have executed Index action of iHome controller and there is no Index.cshtml in your solution. View engine can't find a specific page for your request, so try to add Index.cshtml into /Views/iHome/ or into /Views/Shared/ folders. Also, I can suggest reading this for common understanding how views discovery works.

Upvotes: 1

Related Questions