Solved

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

Posted on 2014-12-23
5
90 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tracing a live website down to the files which support it 2 32
VS 2017 18 108
Convert Silverlight ERP To Angularjs,HTML5 3 61
asp.net figure out error 3 26
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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