asp.net-mvc-5

how to add custom font in asp.net mvc 5

这一生的挚爱 提交于 2019-12-10 17:38:39
问题 I am working on a asp.net mvc5 project and I want to add a font to project and I use below code but I dont get proper answer and I need a help .please help me <style type="text/css"> @font-face { font-family: 'Dense'; src: url('Dense-Regular.ttf'); } .classname { font-family: 'Dense'; } </style> and I get this error The name 'font' does not exist in the current context 回答1: <style type="text/css"> @@font-face { font-family: 'Dense'; src: url('Dense-Regular.ttf'); } .classname { font-family:

create new controller - error running selected code generator

心不动则不痛 提交于 2019-12-10 17:35:12
问题 I am using Visual Studio Express 2013 for Web (specifically version 12.0.21005.1 REL). This is my first project using VS2013, I've been using VS2012 up until this point. I am attempting to create a new controller in my asp.net MVC application. I am using Entity Framework 5 with code first (.NET 4.5). I want Visual Studio to create the template for me (you know, a controller with views to read/write/delete etc, rather than write the code myself from scratch). However, every time I try to

Display only Date in @Html.DisplayFor() in MVC

Deadly 提交于 2019-12-10 17:28:08
问题 I work in MVC5 and EntityFramework for displaying data into View. right now in my view data format is :- 10/22/2014 12:00:00 AM But i want only date :- 22/10/2014 in this format i try this code but it not working @if (item.chekin_on_after != null) { @Html.DisplayFor(modelItem => item.chekin_on_after, "ShortDateTime")} I also follow few link in stackoverflow but not helpful Date Format using Html.DisplayFor() in MVC5, Display only date and no time 回答1: I didn’t use @html.DisplayFor() .Instead

ASP.NET MVC5 application throwing NullReferenceException when authorizing

雨燕双飞 提交于 2019-12-10 17:16:46
问题 I have an MVC5 application that is throwing a NullReferenceException on the production server when using the [Authorize] attribute on a controller. The application is using forms authentication. The production server is Server 2008 SP 2 (.NET 4.5.1 and IIS 7). The start of the stack trace is: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) +38 System.Web.Mvc.AuthorizeAttribute

MVC5 Area not working

核能气质少年 提交于 2019-12-10 17:13:21
问题 I have two Areas in my MVC 5 app that are not working properly. When I use the following Link http://localhost:45970/Admin/Admin the app loads the proper index.cshtml whicxh is located at /Areas/Admin/Views/Admin/Index.cshtml however when I try to load http://localhost:45970/Admin it tries to load the Index.cshtml file from /Views/Admin/Index.cshtml . All the search results say I am doing the correct thing. I have even loaded a sample API project to look at the help area in it to make sure I

How to format DateTimeOffset in Html.TextBoxFor?

筅森魡賤 提交于 2019-12-10 17:07:23
问题 I have a view built on Bootstrap 3 and ASP.NET MVC 5 for editing user profile information, but it displays in the incorrect format on the form. The database is Neo4j and I'm using Neo4jClient to interact with the database from .NET. Neo4jClient requires the use of DateTimeOffset objects instead of DateTime objects to use Json.NET's serializer for passing to Neo4j's REST interface. Therefore, my model uses a DateTimeOffset object to store the birthday for a user. Here is my form field in my

The call is ambiguous beetween the following methods or properties MVC, devexpress

落花浮王杯 提交于 2019-12-10 17:05:29
问题 I have a MVC project and I'm using devexpres 14.1.6. I defined devexpress scripts and stylesheets on _Layout.cshtml page as below head => @Styles.Render("~/Content/css") @Styles.Render("~/Content/Bootstrap/css") @Scripts.Render("~/bundles/modernizr") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/bootstrap") @RenderSection("scripts", required: false) @Html.DevExpress().GetScripts( new Script { ExtensionSuite = ExtensionSuite.NavigationAndLayout }, new Script { ExtensionSuite =

MVC5 EF Entity apparently saving, but is null when retrieved

戏子无情 提交于 2019-12-10 16:54:15
问题 I have an Account class that holds a list of Payments , which holds a list of Products that are Pending , Sold or Refunded . When selecting the Products to pay for, I can add them into a Payment object and then save the whole object to an Account . However, when I retrieve the account in the Pay action, Account.Payments is null. Here is the AddProduct action: public ActionResult AddProduct(List<Product> products) { //var acc = Account.FetchAccountFromIdentity(User.Identity.GetUserName()); var

How to set time zone for ASP.NET MVC 5 application?

北战南征 提交于 2019-12-10 16:46:38
问题 I have quite large web application, which is developed with ASP.NET MVC 5 and MsSql 2008. On my PC, I have +0700 UTC, but on my shared hosting I have other time zone. This code gives me correct DateTime. DateTime utcTime = DateTime.UtcNow; string zoneID = "N. Central Asia Standard Time"; TimeZoneInfo myZone = TimeZoneInfo.FindSystemTimeZoneById(zoneID); DateTime custDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, myZone); Console.WriteLine(custDateTime.ToString()); Unfortunately, I have

_ViewStart and _Layout.cshtml files are automatically created in ASP.NET MVC 5 (annoying)

99封情书 提交于 2019-12-10 16:43:36
问题 I am having a Weird and annoying problem. In my ASP.NET MVC 5 project, time to time, I see that _ViewStart file and Shared/_Layout.cshtml files are created automatically even though I did not want. So, I deleted those files but these files are getting created time to time by itself. That cause a great problem because, sometimes, if I dont notice that these files are created, I can accidentally publish the website and then, after publish, I notice that all pages are being wrapped by the auto