Bogdan Verbenets
Bogdan Verbenets

Reputation: 26936

return specific view

I have a controller at ~/Controllers/MyController.cs and a view ~/Views/My/V1.ascx . How can I return view V1.ascx in a controller's ReturnV1 method? I tried:

return View("V1");

but it returns an empty response instead of my view.

Upvotes: 0

Views: 1560

Answers (2)

Tae-Sung Shin
Tae-Sung Shin

Reputation: 20633

Your view is user control (ascx) file but should be aspx.

Upvotes: 0

M4N
M4N

Reputation: 96541

Did you mean to use PartialView("V1") instead of View("V1") (since the view is called V1.ascx)?

Or do you have another (empty) view named V1.aspx in the same folder? In that case, this will have precedence over the ascx View.

Upvotes: 1

Related Questions