asp.net-mvc-5

MVC Owin Cookie Authentication - Override ReturnUrl Generation

笑着哭i 提交于 2019-12-01 23:18:25
I have an MVC application using Owin Cookie Authentication. I have SlidingExpiration enabled and working. However, when a user's login expires and they are sent back to the LoginPath, the ReturnUrl is giving me some problems: I only want the ReturnUrl to be included if it points to a GET action, not a POST action. I would like to include the PathAndQuery instead of just Path so that I can re-fill any items the user might have had filled in on a form. I tried creating my own AuthorizeAttribute (code below) and applying it to some of the methods in one of my controllers, but it seems like it is

Default datetime picker in visual studio 2015 showing only date picker not allowing to select time

我只是一个虾纸丫 提交于 2019-12-01 23:13:31
I am using visual studiio 2015 and i am using its default datetime picker in my MVC5's App. i am facing problem while showing the datetime picker. it is showing only date picker and not time picker. but i need time picker also. here is my code of datetimepicker in model [DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = false)] [Required(ErrorMessage = "Start DateTime is required")] public Nullable<System.DateTime> start_date_time { get; set; } while i set DateTime in place of Date No Controller comes only textbox appear. There is no default

Moving Identity 2.0 functions to repository class

痴心易碎 提交于 2019-12-01 22:56:01
问题 I am using identity 2.0 for my application and want to move the data functionalities to repository layer such as the following code: public class ApplicationDbInitializer : DropCreateDatabaseIfModelChanges<ApplicationDbContext> { protected override void Seed(ApplicationDbContext context) { InitializeIdentityForEF(context); base.Seed(context); } //Create User=Admin@Admin.com with password=Admin@123456 in the Admin role public static void InitializeIdentityForEF(ApplicationDbContext db) { var

How To Convert Json to google visualization datatable

◇◆丶佛笑我妖孽 提交于 2019-12-01 22:45:13
I have a method with ajax call to the server to get json result var jsonData = $.ajax({ url: '/Reports/GetJsonData', type: 'GET', dataType: 'json', error: function (err) { alert("Error : "+err.statusText); } }).responseText; Then I can get the Following Json result to the "jsonData" variable. [ {"LineName":"L1","Car":23,"Bus":0,"Motorcycle":0,"Person":0,"Others":0} ,{"LineName":"L2","Car":0,"Bus":0,"Motorcycle":6,"Person":0,"Others":0} ,{"LineName":"L3","Car":10,"Bus":20,"Motorcycle":36,"Person":13,"Others":0} ] I want to convert this result to the following format [['LineName', 'Car', 'Bus',

Interfaces for mocking ConfirmEmailAsync and other UserManager methods in MVC5

早过忘川 提交于 2019-12-01 22:33:45
问题 I am trying to unit test this controller method, which comes out of the box in current MVC projects. [AllowAnonymous] public async Task<ActionResult> ConfirmEmail(string userId, string code) { if (userId == null || code == null) { return View("Error"); } var result = await UserManager.ConfirmEmailAsync(userId, code); return View(result.Succeeded ? "ConfirmEmail" : "Error"); } The AccountController has a constructor which will take an ApplicationUserManager and a ApplicationSignInManager as

Moving Identity 2.0 functions to repository class

情到浓时终转凉″ 提交于 2019-12-01 22:11:54
I am using identity 2.0 for my application and want to move the data functionalities to repository layer such as the following code: public class ApplicationDbInitializer : DropCreateDatabaseIfModelChanges<ApplicationDbContext> { protected override void Seed(ApplicationDbContext context) { InitializeIdentityForEF(context); base.Seed(context); } //Create User=Admin@Admin.com with password=Admin@123456 in the Admin role public static void InitializeIdentityForEF(ApplicationDbContext db) { var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>(); var

API Application Insights good practice to use

China☆狼群 提交于 2019-12-01 21:43:58
问题 I read this documentation: https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics There are many different API method to track exceptions, track trace etc.. I have a ASP.NET MVC 5 application. For example, I have the following controller method (called by ajax): [AjaxErrorHandling] [HttpPost] public async Task SyncDriverToVistracks(int DriverID) { if ([condition]) { // some actions here try { driver.VistrackId = await _vistracksService

Interfaces for mocking ConfirmEmailAsync and other UserManager methods in MVC5

穿精又带淫゛_ 提交于 2019-12-01 21:37:09
I am trying to unit test this controller method, which comes out of the box in current MVC projects. [AllowAnonymous] public async Task<ActionResult> ConfirmEmail(string userId, string code) { if (userId == null || code == null) { return View("Error"); } var result = await UserManager.ConfirmEmailAsync(userId, code); return View(result.Succeeded ? "ConfirmEmail" : "Error"); } The AccountController has a constructor which will take an ApplicationUserManager and a ApplicationSignInManager as parameters, and the matching properties with private setters to use for testing. However, I can't figure

Why is IIS Express returning HTTP 500 errors loading javascript and CSS?

旧巷老猫 提交于 2019-12-01 21:33:24
I am trying to develop an ASP.NET MVC5 solution using IIS Express for local debugging. Frequently, Chrome will report HTTP500 errors trying to load certain JS and CSS files (some using the built in bundling and minification feature of MVC, some on their own). WTH is going on with this and how do I stop it? Thanks, Matthew What helped worked is as follows. I am using Visual Studio 2015. Close the visual studio solution. In fact I closed the visual studio itself In the solution folder(the folder which contains the .sln file along with the project folders), you should find a .vs folder. I had

Pass entire object from view to controller in ASP.NET MVC 5

走远了吗. 提交于 2019-12-01 21:28:46
Is there a way to pass entire object from ASP.NET MVC 5 View to a Controller? This is my situation: I have a View that displays all rows from a DB table The view's model is IEnumerable Each row has a link after it's data that leads to the scaffolded UPDATE view Is there a way to pass the entire object to the Update controller method so it would initially fill the form inputs with the old data? Something like: @Html.Action("Update me!", "Update", new { objectFromModelList }) And then in the controller public ActionResult Update(MyType parameter) { return View(parameter); } Or something like