asp.net-mvc-5

how can we make url starts with# using attribute routing in mvc5

拜拜、爱过 提交于 2020-01-07 04:16:08
问题 I want to create a url which starts with # like localhost:/#somename . Can anyone help me? i tried with custom route constraint,i did not get //localhost:/#testing [Route(@"{x:regex([^#]*)}testing")] public ActionResult testingyash(string x) { return View(); } 回答1: You cant have a url like that. The # symbol is a Fragment Identifier. Its used by browsers to identify a section in page. Anything following the # is not even sent to the server. 回答2: Why do you need routing for # value? Those are

Cannot access User.Identity.GetUserId() inside Login action of AccountController in MVC 5

旧街凉风 提交于 2020-01-07 02:26:04
问题 Current Environment Visual Studio 2015, MVC5, Asp.net Identity 2.0, Entity Framework 6.0 Problem I was trying to get User.Identity.GetUserId() after user is just authenticated, but got "Object reference not set to an instance of an object" in the browser. Expectation If it is possible, I want to User.Identity.GetUserID() at the same position. And I wander where the start point is that I can access User.Identity.GetUserId() in the project. Code // // POST: /Account/Login [HttpPost]

MVC 5 Web API Login without Bearer Token

淺唱寂寞╮ 提交于 2020-01-07 02:24:27
问题 Long story short. I have a login form in the header on every single page, when I log in successfully it works fine but when the user is incorrect for example it redirects to the default login page (a view that was originally created with MVC project) with the model errors. I don't want to do that, I want to show errors next to the login form without redirecting. So I decided to implement a login via WEB API - i.e. it does $.ajax jQuery request to the Login API Controller, tries to log user in

Custom Validation MVC 5

随声附和 提交于 2020-01-06 21:42:12
问题 Ok i have this Edit form, what i need is some kind of custom validation for when i enter ReturnDate it Shouldn't be lower then the date of IssueDeadLineDate value. Can i do with Some kind of custom validation or what do i need ? Edit View Picture namespace Library.Models { public class BookStatusView { public int Id { get; set; } public string UserId { get; set; } public DateTime IssueDeadlineDate { get; set; } public DateTime ReturnDeadlineDate { get; set; } public DateTime? ReturnDate { get

Custom Validation MVC 5

十年热恋 提交于 2020-01-06 21:42:11
问题 Ok i have this Edit form, what i need is some kind of custom validation for when i enter ReturnDate it Shouldn't be lower then the date of IssueDeadLineDate value. Can i do with Some kind of custom validation or what do i need ? Edit View Picture namespace Library.Models { public class BookStatusView { public int Id { get; set; } public string UserId { get; set; } public DateTime IssueDeadlineDate { get; set; } public DateTime ReturnDeadlineDate { get; set; } public DateTime? ReturnDate { get

Error trying to update to using SignInManager in Identity 2.0

℡╲_俬逩灬. 提交于 2020-01-06 21:28:05
问题 I am trying to update my login feature to using this line: var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); However I get the following error: Error 1 Using the generic type 'Microsoft.AspNet.Identity.Owin.SignInManager<TUser,TKey>' requires 2 type arguments Before this I had to install a few nuget packages so I think something merely has been missed somewhere, but this is way out my my league! Any help would be hugely

Google Maps from Razor

淺唱寂寞╮ 提交于 2020-01-06 19:52:42
问题 How can I get Google Maps from another Razor ? Hello everyone, I'm trying to solve the problem ... Google Maps Javascript in Create.cshtml, the problem is in Index.cshtml. Index button calls Create.cshtml a Modal Boostrap. How do Index.cshtml getting from a Create.cshtml. Modal works correct, but Google Maps does not work. Create.cshtml <div class="modal fade" id="myModal" role="dialog"> <!-- 'has-error' class has been added on parent form-group div --> <div class="modal-dialog modal-lg"> <!-

ASP.NET MVC 5: single controller method to handle paths in file browser mode

我的未来我决定 提交于 2020-01-06 19:52:33
问题 I want to have some controller with the single method that would allow me to navigate through some hierarchy (file system etc.). In other words I want to have possibility to access this method with flexible routes and get part of routes as parameter. For example in case of this hierarchy Root Sub-folder-A Sub-folder-B Sub-folder-C I want to have access folders with the next routes mymvcapplication/explorer/root mymvcapplication/explorer/root/sub-folder-a mymvcapplication/explorer/root/sub

Asp.net mvc5 value dosen't save to the database

三世轮回 提交于 2020-01-06 15:21:10
问题 Right now I have a MVC5 project that looks like this when creating a post: So I do get a Drop down lsit for both GameId and NextGame which is how I want it. How ever when creating this post only 'GameId' gets saved to the database. While the NextGame Tab would be left at null. Any idea on how I would go a head and fix this? This is my Post model public class Post { [Key] public int PostId { get; set; } //URL [Display(Name = "URL")] [StringLength(80)] [DataType(DataType.Url)] [Required] public

Asp.net mvc5 value dosen't save to the database

一曲冷凌霜 提交于 2020-01-06 15:21:09
问题 Right now I have a MVC5 project that looks like this when creating a post: So I do get a Drop down lsit for both GameId and NextGame which is how I want it. How ever when creating this post only 'GameId' gets saved to the database. While the NextGame Tab would be left at null. Any idea on how I would go a head and fix this? This is my Post model public class Post { [Key] public int PostId { get; set; } //URL [Display(Name = "URL")] [StringLength(80)] [DataType(DataType.Url)] [Required] public