Jake
Jake

Reputation: 3

Why action in controller return view() can direct to other view with same name?

My project called nopCommerce, which is open source.

I download it and start to develop.

When I visit index, run into Index() in HomeController.cs.

public partial class HomeController : BasePublicController
{
    public virtual IActionResult Index()
    {
        return View();
    }
}

return view(), direct to the same view named \Views\Home\Index.cshtml

I can understand it.

This project can plug theme, I plug a theme by copying its code to \Themes\Views\

When I visit this index after plugged, It returns view() directly to \Themes\Views\Home\Index.cshtml

I can not understand it.

Why the action in controller return view() can direct to other view with same name?

I try to renamed \Themes\Views\Home\Index.cshtml

It direct to \Views\Home\Index.cshtml

Upvotes: 0

Views: 268

Answers (2)

Jake
Jake

Reputation: 3

I found it,the project will set ViewLocationExpanderContext by theme name

Upvotes: 0

Mirzan
Mirzan

Reputation: 94

Obviously you got to do certain changes in RouteConfig.cs or using [ActionName("")]

Upvotes: 0

Related Questions