1

I've renamed some views in my MVC project and then changed the controller to reflect the change but for some reason it still cannot find the view.

My action is as follows:

 // GET: Accounts public ActionResult Index() { return View("Find", db.Accounts.ToList()); } 

And as you can see from this screenshot, the view is there where it should be:Views

Is there something I've missed?

7
  • 2
    What controller class is that action in? Commented Nov 18, 2015 at 0:24
  • What is the controller called? Have you got any custom routing? Commented Nov 18, 2015 at 0:25
  • It's in an AccountsController, there's no custom routing and yeah I've rebuilt - if I rename the ActionResult to the same as the view it works, but I thought I didn't need to do that? Commented Nov 18, 2015 at 0:27
  • And what is the URL you are using to access this method? Commented Nov 18, 2015 at 0:28
  • 1
    No, that's just telling the action which view to use when rendering. Commented Nov 18, 2015 at 0:31

1 Answer 1

1

By default in MVC, the routing says you access an action in this format:

http://server/controller/action 

Changing the view used doesn't affect the routing at all. So if you want to access the action, you can either use a proper URL:

http://server/accounts/index 

This should also work but depends on your routing as Index is often the default action:

http://server/accounts 

Alternatively you could add a custom route just for that action.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.