mvc view without controller

ITsolutionWizard used Ask the Experts™
I have searched on Google about creating view without controller but most of them shown me I can do it using redirect so I try out.

the result is because the app redirect so many time n it ends up it time out or generate error message.

if you have the same situation please show me how to handle this.

the reasons we don't want to use controller is because we will create many landing page from our web designer. and there is no need to generate any model, but we do want to use cshtml to do some server side work.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I couldn't believe it when I saw it, but it does work.  Abhimanyu K Vatsa wrote an article about this in 2013; it provides exactly what we need to make this happen.

In his article we discover that there are two things we need to do:
1. Override HandleUnknownAction() in the controller that will provide the route to the "orphaned" Views.
2. Add the "orphaned" views to the /Views folder for the controller overridden in #1 above

I chose to override the Home controller because it was already there. I simply added the following block of code to the otherwise untouched HomeController.cs:
protected override void HandleUnknownAction(string actionName)

Open in new window

Then I added three views to the /Views/Home folder.

After that, standard links such as the following will work as expected.
<div class="row">
	<div class="col-md-4">
		<p><a class="btn btn-default" href="/Home/One">Go to View #1 &raquo;</a></p>
	<div class="col-md-4">
		<p><a class="btn btn-default" href="/Home/Two">Go to View #2 &raquo;</a></p>
	<div class="col-md-4">
		<p><a class="btn btn-default" href="/Home/Three">Go to View #3 &raquo;</a></p>

Open in new window

To verify that this works (six years later!) I created a .NET Standard 4.7.1 MVC solution using Visual Studio 2017.
I couldn't attach the file directly to this answer so I've shared it via my OneDrive.
ǩa̹̼͍̓̂ͪͤͭ̓u͈̳̟͕̬ͩ͂̌͌̾̀ͪf̭̤͉̅̋͛͂̓͛̈m̩̘̱̃e͙̳͊̑̂ͦ̌ͯ̚d͋̋ͧ̑ͯ͛̉Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Just out of curiosity, why would you want to do this? It would seem to be a non-standard way of doing things in MVC, and it could lead to confusion for the maintainer of the code in the future. Your controller doesn't need to do a crazy amount of work. It can simply return the view instances, like what you see in the sample code of a new MVC project.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial