Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 94
  • Last Modified:

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

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
danielolorenz
Asked:
danielolorenz
  • 3
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
danielolorenzAuthor Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
What is your view called?  Is it called "Search", or is it called "Index"?
0
 
danielolorenzAuthor Commented:
It is called Search
0
 
Carl TawnSystems and Integration DeveloperCommented:
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now