iam beginner to mvc and iam using mvc4.0
Iam getting this error CS0103: The name 'url' does not exist in the current context
What I have tried:
Layout.cshtml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href ="@url.Content("~/Content/Site.css")rel ="stylesheet" type ="text/css"/>--error on this line
<script src ="@url.Content("~/Scripts/jquery-1.8.3.js")" type ="text/javascript"></Script>
<script src ="@url.Content("~/Scripts/jquery-ui.min.js")" type ="text/javascript"></Script>
<link href ="@url.Content("~/Content/jquery-ui.min.css")rel ="stylesheet" type ="text/css"/>
<link href="@Url.Content("~/Content/site"))"
rel="stylesheet" type="text/css" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<header>
@Html.ActionLink("your logo here", "Index", "Home")
@Html.Partial("_LoginPartial")
</header>
@RenderSection("featured", required: false)
© @DateTime.Now.Year - My ASP.NET MVC Application
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
-------------------------
Index.cshtml
@model insertupdatedelete.Models.mobileda
@{
ViewBag.Title = "Index";
Layout ="~/Views/Shared/_Layout.cshtml";
}
Index
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
mobileda
@Html.LabelFor(model => model.MobileID)
@Html.EditorFor(model => model.MobileID)
@Html.ValidationMessageFor(model => model.MobileID)
@Html.LabelFor(model => model.MobileIDd)
@Html.EditorFor(model => model.MobileIDd)
@Html.ValidationMessageFor(model => model.MobileIDd)
@Html.LabelFor(model => model.MobileName)
@Html.EditorFor(model => model.MobileName)
@Html.ValidationMessageFor(model => model.MobileName)
@Html.LabelFor(model => model.MobileIMEno)
@Html.EditorFor(model => model.MobileIMEno)
@Html.ValidationMessageFor(model => model.MobileIMEno)
@Html.LabelFor(model => model.mobileprice)
@Html.EditorFor(model => model.mobileprice)
@Html.ValidationMessageFor(model => model.mobileprice)
@Html.LabelFor(model => model.mobileManufacured)
@Html.EditorFor(model => model.mobileManufacured)
@Html.ValidationMessageFor(model => model.mobileManufacured)
@Html.LabelFor(model => model.Datetime)
@Html.EditorFor(model => model.Datetime)
@Html.ValidationMessageFor(model => model.Datetime)
<input type="submit" value="Create" />
}
<Script type ="text/javascript">
$(document).ready(function () {
$("Datetime").datepicker();
});
</Script>
@Html.ActionLink("Back to List", "Index")
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
--------------------
View webconfig
<configuration>
<configsections>
<sectiongroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<system.web.webpages.razor>
<host factorytype="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<pages pagebasetype="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc">
<add namespace="System.Web.Mvc.Ajax">
<add namespace="System.Web.Mvc.Html">
<add namespace="System.Web.Optimization">
<add namespace="System.Web.Routing">
<appsettings>
<add key="webpages:Enabled" value="false">
<system.web>
<httphandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler">
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages>
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagprefix="mvc">
<system.webserver>
<validation validateintegratedmodeconfiguration="false">
<handlers>
<remove name="BlockViewHandler">
<add name="BlockViewHandler" path="*" verb="*" precondition="integratedMode" type="System.Web.HttpNotFoundHandler">
---------------------------------
main webconfig
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configsections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<connectionstrings>
<add name="mycon" connectionstring="Data source = PRABHU-PC ; database = welcometesting; integrated security = true;" providername="System.Data.SqlClient">
<appsettings>
<add key="webpages:Version" value="2.0.0.0">
<add key="webpages:Enabled" value="true">
<add key="PreserveLoginUrl" value="true">
<add key="ClientValidationEnabled" value="true">
<add key="UnobtrusiveJavaScriptEnabled" value="true">
<system.web>
<compilation debug="true" targetframework="4.0">
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers">
<add namespace="System.Web.Mvc">
<add namespace="System.Web.Mvc.Ajax">
<add namespace="System.Web.Mvc.Html">
<add namespace="System.Web.Optimization">
<add namespace="System.Web.Routing">
<add namespace="System.Web.WebPages">
<system.webserver>
<validation validateintegratedmodeconfiguration="false">
<modules runallmanagedmodulesforallrequests="true">
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit">
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit">
<remove name="ExtensionlessUrlHandler-Integrated-4.0">
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptprocessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" precondition="classicMode,runtimeVersionv4.0,bitness32" responsebufferlimit="0">
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptprocessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" precondition="classicMode,runtimeVersionv4.0,bitness64" responsebufferlimit="0">
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" precondition="integratedMode,runtimeVersionv4.0">
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentassembly>
<assemblyidentity name="System.Web.Helpers" publickeytoken="31bf3856ad364e35">
<bindingredirect oldversion="1.0.0.0-2.0.0.0" newversion="2.0.0.0">
<dependentassembly>
<assemblyidentity name="System.Web.Mvc" publickeytoken="31bf3856ad364e35">
<bindingredirect oldversion="0.0.0.0-4.0.0.0" newversion="4.0.0.0">
<dependentassembly>
<assemblyidentity name="WebGrease" publickeytoken="31bf3856ad364e35">
<bindingredirect oldversion="0.0.0.0-1.6.5135.21930" newversion="1.6.5135.21930">
<entityframework>
<defaultconnectionfactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0">