asp.net-mvc-5

Adding new Theme to ASP.Net MVC 5 dont work

社会主义新天地 提交于 2019-12-10 23:07:29
问题 I have the following Problem. When i try to add a new Theme to ASP.Net MVC 5 my Navbar get crashed. When i use the Standard Bootstrap it works. I have no idea why it dont work. This is my BundleConfig: bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap-lumen.css", "~/Content/site.css")); This is the Standard MVC _Layout.cshtml Page: <div class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class=

Passing Datas from cshtml to custom edit for not working

断了今生、忘了曾经 提交于 2019-12-10 22:59:08
问题 This is my code in .cshtml . I want to pass value of css to my custom edit for but not working. @Html.EditorFor(model => model.xxx, new { size = 20, maxLength = 10 , css = "test" }) my code in custom edit for. @model string @{ int size = 50; int maxLength = 50; string type = "text"; string css = ""; if (ViewData["size"] != null) { size = (int)ViewData["size"]; } if (ViewData["maxLength"] != null) { maxLength = (int)ViewData["maxLength"]; } if (ViewData["type"] != null) { type = (string

How to correctly catch exception raised by view or even controller in ASP.Net MVC 5 project

风格不统一 提交于 2019-12-10 22:22:09
问题 Ok, I am newbie in ASP.Net MVC 5 and working on a small already existing project so bear with me. I am finding it hard to understand/handle/decode exception raised in my code. Here is the way the exception is getting handled in the project: public class BaseController : Controller { protected override void OnException(ExceptionContext filterContext) { if (!filterContext.ExceptionHandled) { filterContext.ExceptionHandled = true; Response.StatusCode = 500; Response.StatusDescription = Constants

Owin Context to use a single instance per request

核能气质少年 提交于 2019-12-10 21:53:07
问题 app.CreatePerOwinContext(DataContext.Create); I have the above line to create a data context this code came with project when i kick a new MVC 5 project. At the same time, i am using autofac to inject single instance per request in my dependency registrar. builder.RegisterType<DataContext>().As<IDbContext>().InstancePerRequest(); What is the best way to use owin and DI container? I have a DataContext class which has a static Method called Create as above and this break when I try to inject a

MVC 5 current claims autorization and updating claims

旧时模样 提交于 2019-12-10 21:44:19
问题 I have 2 questions regarding the claims: 1) In .Net 4.5 and MVC 5 how does the microsoft implements the autorization, when you set on controller AuthorizeAttirubte, does it check the database to get the user role? Or it uses the claims? I've read somewhere that microsoft uses database each time to verify the role, and they advised to write a new AuthorizeAttribute to implement claims authentication. This is the article i'm talking about: http://kevin-junghans.blogspot.be/2013/10/improving

Correct way of setting the role for user when he is registered with Identity

人走茶凉 提交于 2019-12-10 21:35:16
问题 I have a question, I'm new to identity, but still i would like to know what would be the correct way of assigning role to a user when he is registering? I have here a code: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.UserName }; RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));

How to save time only without the date using ASP.NET MVC 5 Data Annotation "DataType.Time?

你说的曾经没有我的故事 提交于 2019-12-10 21:34:09
问题 My Model Class looks like this: [DataType(DataType.Time)] public DateTime Time {get; set;} When I run it, I have a cool an HTML 5 Input Type in Time. When I save the data, the value in my database looks like this: 7/11/2014 1:00AM It automatically saves the current date. I just wanna have the time saved. I'm trying to create a reservation system. 回答1: In that case you need to store that as a string. You cannot separate Time from Date using BCL (Base Class Library) of .Net. They cannot exist

How to build and publish .NET MVC and Web API projects to their different folders

拜拜、爱过 提交于 2019-12-10 20:25:08
问题 I have a solution which contains MVC and WebApi projects. What I want to do is to to publish them both with a single click. I would like MVC project to go to a root folder ..\MyApp\ and WebApi to ..\MyApp\Api\ . I think I've seen such solution, but I just cannot find it any where. 回答1: The physical path is going to be determined by your publishing method. You could set up the publishing wizard to just point to the physical path that you want. Then you'd have to configure IIS to ensure that

Unable to login to PiranhaCMS after setup

一个人想着一个人 提交于 2019-12-10 19:43:55
问题 I've installed PiranhaCMS on an existing ASP.NET MVC5 application. Part from I had to install AutoMapper, the installation went through smouthly. I followed the Get Started instruction in the "Adding Piranha CMS to an existing application". I've tried using existing database, the incluede CE database, and event with a new database. It all comes down to the same problem, I get routed to "/manager/install" where I set up the admin user (which gets added to the sysuser table). After this I get

ModelState.AddModelError to a particular ValidationMessageFor of a field?

非 Y 不嫁゛ 提交于 2019-12-10 19:42:28
问题 I have the following code to generate an html input and validation message. @Html.ValidationSummary(false) ...... <div class="col-md-10"> @Html.TextBoxFor(model => model.ImageUpload, new { type = "file", name = "file" }) @Html.ValidationMessageFor(model => model.ImageUpload) </div> In my action I have the code if (.... something wrong with the input ....) { ModelState.AddModelError("", "Invalid image file."); return RedirectToAction(.... However, it will show an error message in the