asp.net-mvc-5

ASP.NET Vnext Tag Helpers for Areas

放肆的年华 提交于 2019-12-04 21:14:27
I may use <a href='/Area/Controller/action'> </a> in asp.net vnext but just want to know whether we can use tag helpers like <a asp-controller="ControllerName" asp-action="ActionName" asp-area="AreaName"> to redirect to the specific file in the area. Will any one guide me how to redirect to a file in area using tag helpers.? Finally I got the answer from the following link which works well. <a asp-route-area="AreaName" asp-controller="ControllerName" asp-action="ActionName"> </a> github link Christoph Brückmann If you use ReSharper it's IntelliSense could also override the Tag Helpers. I

Passing a variabe to jquery using Odometer

大憨熊 提交于 2019-12-04 20:40:36
I would like to use a jquery odometer to display information on a master page. http://www.jqueryscript.net/animation/Smooth-Animated-Numbers-with-Javascript-CSS3-odometer.html In order to do that I have to retrieve that value from SQL Server using C#. Then I have to pass it to the jscript odometer in the html() as shown below. If I get the valuje - how do Isend it to the javascript? <script> setTimeout(function(){ $('.odometer').html('123222'); }, 1000); </script> You can use the below implementation to pass the value from code behind to Jquery This is one example how to do it. First Declare a

Identity UserManager.AddToRole throws exception

折月煮酒 提交于 2019-12-04 19:54:57
As the title says I am using the new C# MVC 5 Identity doing a simple call: UserManager.AddToRole(User.Id, User.RequestedRole); I am doing this in a method of my ViewModel that is called from the Controller The UserManager is created in the Base Class of my ViewModel like this: UserManager = new UserManager<TMUser>(new UserStore<TMUser>(new TMContext())); When I make the above call to AddToRole method, I get this Inner Exception (The outer one is generic/useless): {"A relationship from the 'Ledger_User' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding

ASP.Net Identity 2 Reset password with SMS

↘锁芯ラ 提交于 2019-12-04 19:38:48
问题 I'm looking to send the user an SMS when reseting their password. I already have the facilities to send a SMS, I just need a guide on how to set it up with Identity 2.0. I can't seem to find any useful info online, the reference code itself isn't properly commented either. I want to generate a security code, send it to the user, he must then input it into a form and then be allowed to reset his/her password. Can anyone direct me to a guide/tutorial that explains this process? 回答1: After

MVC5 Identity/OWIN - Signout events

蓝咒 提交于 2019-12-04 19:29:53
How to detect all possible SignOuts? Is there a way to get some event when SignOut is made manually, by timeout and any other possible ways? I need to know when user authentication ends like i know that it starts when SingIn is called. I'm using both internal accounts and external (like Facebook). I need a spot that i can initialize user session when user is already authenticated. Below is code that should do the job, i don't like it at all. I need to check session at each request to be sure that flag in session is already loaded and was loaded for current user. In future that flag will be

Show custom error for “504 Gateway Timeout error”

大憨熊 提交于 2019-12-04 19:10:19
I am working to ASP.net MVC-5 project and I am a beginner. As of now I know the basics of MVC and able to display pages and make post and get request. But I am stuck with one issue where I get "504 gateway time out error" and I need to implement one functionality where if the client gets `504 gateway timeout error" I should be able to show a particular page like "Something is wrong" instead of standard error. To start with below is what I did. <system.web> <compilation debug="true" targetFramework="4.5.1" /> <httpRuntime targetFramework="4.5" /> <customErrors mode="On" redirectMode=

Could not load file or assembly System.Web.Mvc or one of its dependencies

妖精的绣舞 提交于 2019-12-04 18:49:26
问题 currently working on asp.net mvc5 (old mvc3 project). It builds just fine, but when I start the project but when I run the project I am facing the following error. Could not load file or assembly 'System.Web.Mvc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Not sure how I can can fix this, any ideas? This is the Assembly Load Trace: === Pre-bind state information === LOG: DisplayName = System

MVC5 Object reference not set to an instance of an object on Scripts.Render

◇◆丶佛笑我妖孽 提交于 2019-12-04 18:40:04
问题 I'm using Asp.net MVC5 and haven't encountered such this ambiguous error since 4 years working with Microsoft MVC platform! The error occurs in Manage page in default MVC5 template. here in line 26 at the _layout.cshtml file: Line 24: <![endif]--> Line 25: Line 26: @Scripts.Render("~/js/intf") Line 27: <script> Line 28: if (document.documentMode === 10) { The Stack Trace says: [NullReferenceException: Object reference not set to an instance of an object.] ASP._Page_Views_Shared__Layout_cshtml

How to design an MVC5 Global Search feature in Layout.cshtml

为君一笑 提交于 2019-12-04 17:44:18
I am trying to implement a "global search" feature, that is available above our main menu, in all Views within our application. It looks like this: The "global search" is a jQuery autocomplete input field. It resides in our _Layout.cshtml, which is a shared View and gets loaded many times by other views. Essentially it will display an auto-suggestion list for search keywords. Our list of keyword suggestions is roughly 6000 items. Our HomeController looks like this: public class HomeController : Controller { public ActionResult Index() { return View(); } public ActionResult Home() { ViewBag

Viewbag.Title error: One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

余生长醉 提交于 2019-12-04 17:43:11
问题 I have an ASP.NET MVC 5 web application. In every .cshtml view file i get the following error for Viewbag : One or more types required to compile a dynamic expression cannot be found. Are you missing a reference? I have references to Microsoft.CSharp.dll and System.Core.dll. Here is my root web.config file: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework