asp.net-mvc-5

How to map Entity Framework model classes with Business Layer class in n-tier architecture - ASP.NET-MVC

烈酒焚心 提交于 2019-12-21 02:36:07
问题 I am working on e-tier architecture within MVC framework (ASP.NET MVC5, Entity Framework 6). My application is divided into three sub-projects which are Business-Layer, Data-Access-Layer, Repository (This include repository and Unit of Work) and ASP.NET MVC web-app. I am struggling to understand mapping between business data and entity framework model. for example if I have model class User in entity framework as DAL - User Model [Table("User")] public class User { public User() { } [Key]

How to refresh ASP .NET MVC page when hitting browser back button

丶灬走出姿态 提交于 2019-12-20 21:59:31
问题 I just found that when I click browser back button on any ASP .NET MVC page nothing happens and page is not going be updated. And only if you click F5 it will be updated only. The main problem that I do some changes of DOM of the page i.e. add table rows select radio-buttons and etc and when I go back to page by hitting browser back button I have see no changes. How it can be resolved for ASP .NET MVC 5? Thank for any clue... P.S. I have read http://forums.asp.net/t/1304752.aspx?how+to

Render a View after an AJAX call in asp.net MVC

懵懂的女人 提交于 2019-12-20 20:26:49
问题 I'm trying to load a view after an ajax call. After the ajax call my action method will return a view which is going to be loaded after the call is success. AJAX I'm using function PostMethods(url, fname, lname, email) { var userRegisterViewModel = { FirstName: fname, LastName: lname, Email: email }; $.ajax({ type: 'Post', dataType: "json", url: url, contentType: 'application/json', data: JSON.stringify(userRegisterViewModel), //Success and error code });} My ajax calling an api method where

Web API 2 / MVC 5 : Attribute Routing passing parameters as querystring to target different actions on same controller

十年热恋 提交于 2019-12-20 19:42:48
问题 I've been playing with the new Web API 2 (which looks very promising btw) but I'm having a bit of a headache to get some routes working. All works fine when I have GetAllUsers / GetUser(int id), but then when I add GetUserByName(string name) and/or GetUserByUsername(string username) things start to be creepy. I know that the int will be the first one and that I can re-order the routes but let's imagine the following scenario: A user can have a valid username=1234 or name=1234 (I know it's

CookieAuthenticationOptions, ExpireTimeSpan does not work

こ雲淡風輕ζ 提交于 2019-12-20 18:44:11
问题 I have the following code: public void ConfigureAuth(IAppBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, ExpireTimeSpan = System.TimeSpan.FromMinutes(1), LoginPath = new PathString("/Account/Login"), LogoutPath = new PathString("/Account/LogOff") }); But login session active more than 1 minute. Also, LogoutPath is not called when time is expired. Why? 回答1: It does expire. Make sure you do not have

How to download a specific version of ASP.NET MVC 5 source code

喜夏-厌秋 提交于 2019-12-20 17:56:30
问题 I'm looking for ASP.NET MVC 5.0 RTM source code. I've tried to download this from http://aspnetwebstack.codeplex.com/ but it seems to have only the most recent version 5.1.1 RTM. I've tried with no success to download for a specific tag or branch. In Source Code tab, in field "Browsing Changes in" the only options are "master" or "v3-rtm". Could someone help me with this? 回答1: As per their wiki: MVC 5.2.3 RTM = v3.2.3 (commit 0e974218e12a) https://aspnetwebstack.codeplex.com/SourceControl

MVC: How to get controller to render partial view initiated from the view

放肆的年华 提交于 2019-12-20 16:31:39
问题 In my MVC5 project I want to create a menu in a partial view. This menu is dynamic in the sense that it is built from content in my database. Thus I have a controller taking care of creating my menu and returning the menu model to my partial view: public PartialViewResult GetMenu() { MenuStructuredModel menuStructuredModel = menuBusiness.GetStructuredMenu(); return PartialView("~/Views/Shared/MenuPartial", menuStructuredModel); } In my partial view called MenuPartial I want to use razor to

How to pass information from OnAuthenticated event to a controller and SignIn?

一曲冷凌霜 提交于 2019-12-20 15:25:49
问题 As I've found out here, I can't call HttpContext.GetOwinContext().Authentication.SignIn(...) in FacebookAuthenticationProvider OnAuthenticated event. It seems to be a different context. My users will be from Facebook, which means that I will need to retrieve data such as id , email ... This information is accessible on the OnAuthenticated event and I need this information to SignIn. I need to access this information on my controller... I tried this in the event: context.OwinContext.Set(

Display error message on the view from controller asp.net mvc 5

…衆ロ難τιáo~ 提交于 2019-12-20 11:14:36
问题 I am new to web development and trying to learn ASP.Net MVC 5. I am looking for one record in database if the record is not found then I want to display an error message to the user. Below is my attempt: Controller [HttpGet] public ActionResult Search() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Search(ForgotPasswordMV viewModel) { if (Temp.Check(viewModel.Email)) return RedirectToAction("VerifyToken", new { query = viewModel.Email }); else { ViewBag

How to list users with role names in ASP.NET MVC 5

落爺英雄遲暮 提交于 2019-12-20 10:37:48
问题 I have default project template of ASP.NET MVC 5 web site and I am trying to list all users with role names (not IDs). The query is: db.Users.Include(u => u.Roles).ToList() Then I want to print the role names with something like: @string.Join(", ", user.Roles.Select(r => r.RoleId)) The problem is that I can reach only RoleId , not Role class where Name and other properties are stored. I could run another select to get all roles and then use that as a lookup. Or write a join in the query