Solved

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

Posted on 2014-12-23
5
83 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
Comment Utility
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
Comment Utility
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
Comment Utility
What is your view called?  Is it called "Search", or is it called "Index"?
0
 

Author Comment

by:danielolorenz
Comment Utility
It is called Search
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now