Ok so I am working with an ASP.NET MVC 3 project. When I first started to learn C# ASP.NET, I created a strongly typed view for a controller action. However, I now realized that I don't need that model (model that my view was strongly typed to) anymore. How can I get rid of the model? I tried excluding it from the project but when I compile my project in VS2010, it says that The page not found
. Is there any way to undo the strongly typed part in VS2010 and still be able to keep and display stuff in my view?
Edit:
@using IntraNet.Areas.Roc.Models.ViewModels; @* This is for SiteLookupVM *@
@{ Layout = "~/Views/Shared/_LayoutIntranet.cshtml"; }
<div id="mdPageHdr">FindnSave Metrics</div>
@Html.Partial("_PartialSiteLookup", (SiteLookupVm) ViewBag.SiteLookup)
@if (ViewBag.SiteId > 0)
{ @Html.ActionLink("Bounce Metrics", "BounceMetrics", "Metrics",new { siteId = @ViewBag.SiteId }, null)
@Html.Partial("_PartialChartDisplay")
}
else
{
<div id="tabsWrapper">
<ul id="tabs_menu">
<li>@Html.ActionLink("Page Loads", "Index", null, new { id = "active" })</li>
<li>@Html.ActionLink("Metrics Data", "DashMetrics")</li>
</ul>
</div>
<div id='dashboard'>
@Html.Partial("_partialMetricsDashboard")
</div>
}
Action
protected MetricsDashboardRepository _mdr = new MetricsDashboardRepository();
private LoadHistoryDBEntities db = new LoadHistoryDBEntities();
private AvailabilityContext context = new AvailabilityContext();
public ActionResult Index(int? SiteId)
{
SiteLookupVm SiteLookup = new SiteLookupVm();
SiteLookup.ActionName = "Index";
SiteLookup.ControllerName = "Metrics";
ViewBag.SiteLookup = SiteLookup;
ViewBag.Title = "FNS Metrics";
if (SiteId != null && SiteId > 0)
{
string site = new WPDE().Sites.Where(r => r.SiteId == SiteId).Select(r => r.Name).FirstOrDefault();
SiteLookup.CurrentSite = site == null ? "Site does not exist" : site;
ViewBag.SiteId = SiteId;
ViewBag.FnsId = db.fns_sites.Where(f => f.3id == SiteId && f.enabled).Select(s => s.id).FirstOrDefault();
ViewBag.RegionData = context.Regions.ToList();
ViewBag.PathData = context.TestPaths.ToList();
}
else
{
_mdr.DashSetup();
ViewBag.mdr = _mdr;
ViewBag.date = 30;
ViewBag.order = 0;
ViewBag.totPageView = _mdr.TotPageView();
ViewBag.totMonthUni = _mdr.TotMonthUni();
}
return View();
}
In the top of your view, you should see something like this:
Razor:
@model YourType
ASPX:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<YourType>" %>
If it's Razor, remove that line. If it's ASPX, change <YourType>
to <dynamic>
Regards