asp.net - Getting Server error while using c# -
i getting following error while trying add model , display data in view using asp.net mvc2 application.
error:
server error in '/' application.
compilation error
description: error occurred during compilation of resource required service request. please review following specific error details , modify source code appropriately.
compiler error message: cs0246: type or namespace name 'mvcinputscreen' not found (are missing using directive or assembly reference?)
source error:
line 158:
line 159: [system.runtime.compilerservices.compilerglobalscopeattribute()] line 160: public class views_customer_displaycustomer_aspx : system.web.mvc.viewpage, system.web.sessionstate.irequiressessionstate, system.web.ihttphandler { line 161:
line 162: private static bool @__initialized;source file: c:\windows\microsoft.net\framework\v4.0.30319\temporary asp.net files\root\36f3c2d6\5d16a5e9\app_web_displaycustomer.aspx.90494039.kvpkqitq.0.cs line: 160
show detailed compiler output:
show complete compilation source:
the following code files.
customercontroller.cs:
namespace mydemo.controllers { public class customercontroller : controller { // // get: /customer/ public viewresult displaycustomer() { customer objcustomer = new customer(); objcustomer.id = 12; objcustomer.customercode = "1001"; objcustomer.amount = 90.34; return view("displaycustomer", objcustomer); } } } customer.cs
using system; using system.collections.generic; using system.linq; using system.text; namespace mydemo.controllers { class customer { private string _code; private string _name; private double _amount; public string code { set { _code = value; } { return _code; } } public string name { { return _name; } set { _name = value; } } public double amount { set { _amount = value; } { return _amount; } } public string customercode { get; set; } public int id { get; set; } } } displaycustomer.aspx:
<%@ page language="c#" inherits="system.web.mvc.viewpage<mvcinputscreen.models.customer>" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>displaycustomer</title> </head> <body> <div> customer id <%= model.id %><br /> customer code <%= model.customercode %><br /> <% if (model.amount > 100) {%> priveleged customer <% } else{ %> normal customer <%} %> </div> </body> </html> please me resolve error.as new asp.net want know how set route file here means suppose have 3 view files (i.e-index,create,details) want set 1 file @ time such way if typing http://localhost:port no page come directly.
your page expecting system.web.mvc.viewpage<mvcinputscreen.models.customer>" while customer class in mydemo.controller namespace should change system.web.mvc.viewpage".
also recommend change namespace of
modelclassesmydemo.controllersmydemo.models.
Comments
Post a Comment