Solved

I Added a New Page and Controller on MVC and Get an Internal Server Error?

Posted on 2014-12-23
5
89 Views
Last Modified: 2014-12-26
I am building a new MVC Application.  I added a new page and a new controller.  When I go to the new page, I get the following error: The page cannot be displayed because an internal server error has occurred.

Do you know how to fix this error?

Thanks,

Dan
0
Comment
Question by:danielolorenz
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40514943
That's a bit too vague to be able to answer straight off the bat.  Firstly, can you tell if your controller is being hit or not? Put a break point on whatever action is being called by default and see if it is hit when you run your project.

A bit more detail about your controller, view and what both are doing would be helpful.
0
 

Author Comment

by:danielolorenz
ID: 40515024
Yes, I am hitting the controller.  I set a break point in the controller and it is hitting the ActionResult Index().

I wrote a basic Controller and a Basic view with the view returning to the controller.

I Wrote a basic Controller:
using System.Web.Configuration;
using System.Web.Mvc;

namespace BCA.GunPermit.Controllers
{
    public class GunPermitSearchController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
}

Open in new window


View:
@{
    ViewBag.Title = "Search";
}

<h2>Search Test</h2>

<br />

<div class="gun-permit-search">
    <div id="search-purpose-code" class="well well-sm">


    </div>
</div>

Open in new window

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40515027
What is your view called?  Is it called "Search", or is it called "Index"?
0
 

Author Comment

by:danielolorenz
ID: 40515046
It is called Search
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40515103
That's your problem then.  If you return View() then the view needs to have the same name as the action (i.e. Index in your case).  Or, alternatively, you can pass the name of the view if it is different to the action name:
public ActionResult Index()
{
    return View("Search");
}

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Finding Events logs for IIS website that restarts 2 14
VB.NET Textbox input validation 4 37
Input parameteres to DragOver 2 19
Adding items to a C# list incrementally 5 30
IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question