asp.net-mvc-5

Typescript files not compiling on Angular 2 with Visual Studio 2015

牧云@^-^@ 提交于 2019-12-01 09:21:05
I followed Zach's Answer and create new VS 2015 .NET 5 project and run Angular 2 with Typescript. It looks like its working. But there is a little problem: MyApp.ts : import { Component } from "angular2/core"; @Component({ selector: "my-app", template: ` <div>Hello from Angular 2</div> ` }) export class MyApp { public constructor() { } } When i change the template, type some different text, lets say <div>Some text here</div> , and then i recompile the project and run in browser to see the change - it still shows the older template text - Hello from Angular 2 . So i checked in the MyApp.js

MVC5 using MvcSiteMapProvider to build twitter bootstrap menu

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 09:09:19
问题 Default menu section in MVC5 template looking like that: <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("About", "About", "Home")</li> <li>@Html.ActionLink("Contact", "Contact", "Home")</li> </ul> @Html.Partial("_LoginPartial") </div> _LoginPartial looking like that: @using Microsoft.AspNet.Identity @if (Request.IsAuthenticated) { using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id =

I can't seem to get a very basic cookie login example to work with MVC5 and OWIN

此生再无相见时 提交于 2019-12-01 09:05:30
I've been trying to get my feet wet with ASP.net MVC 5 for 2013, but so far I've failed to get even the most basic authentication working correctly. I've been reading around for the last few days and I finally stumbled upon ( http://brockallen.com/2013/10/24/a-primer-on-owin-cookie-authentication-middleware-for-the-asp-net-developer/ ) which seemed to give the most basic simple example I could find. So I tried that, but it still fails to seem to actually create a session for the user. Here is my cookie config public void ConfigureAuth(IAppBuilder app) { app.UseCookieAuthentication(new

DateCreated and DateModified in ASP.NET MVC 5

余生颓废 提交于 2019-12-01 08:37:58
I am working on a Code-First project, and I need database to handle DateCreated and DateModified . The application is running on IIS Express with LocalDB on dev machine, and will be using SQL Server 2012 on deployment server with IIS 7.5. I have the following model: public class Person : IdentityUser { [Required] public string Name { get; set; } public Date DateOfBirth { get; set; } public string Address { get; set; } [DatabaseGeneratedOption.Identity] public Date DateCreated { get; set; } [DatabaseGeneratedOption.Identity] public Date DateModified { get; set; } } Please lay out exact steps to

Asp MVC: How get roles from ApplicationUser

北城以北 提交于 2019-12-01 08:31:28
In ASP.NET MVC 5, in a controller, I have take the user that has make the request with: ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); With the ApplicationUser instance, how can i get all the Roles of the user? You can get user and assigned roles by using UserManager. var userManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); and then you can get your user like you already did, and also you can get roles for particular user by

FileLoadException after installing Ninject.MVC5

若如初见. 提交于 2019-12-01 08:15:46
I am trying to learn ASP.NET MVC with Adam Freeman's "Pro ASP.NET MVC 5" book. Unfortunately all projects using Ninject throw the same error An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not >handled in user code Additional information: Could not load file or assembly 'System.Web.Mvc, >Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its >dependencies. The located assembly's manifest definition does not match the assembly >reference. (Exception from HRESULT: 0x80131040) This is exactly the same problem which was discussed in this

Can't check in .mdf/.ldf in App_Data into TFS

一笑奈何 提交于 2019-12-01 08:08:02
I am working with ASP.NET C# MVC 5. .mdf/.ldf files in App_Data do not appear on Pending Changes in team explorer. Therefore I can't check them into TFS(visual studio online). I've tried recreating the project a few times and none worked. What might be the cause for this? Go to Team Explorer and locate Excluded Changes and you should find it excluded. Right click the App_Data folder and include it. But you might want to reconsider including the database files. As you're developing and testing, every little database interaction will trigger a change and most of those are trivial. Also, if

How can I programmatically stop the current website? [duplicate]

一笑奈何 提交于 2019-12-01 08:03:23
问题 This question already has answers here : How can I programmatically stop or start a website in IIS (6.0 and 7.0) using MsBuild? (3 answers) Closed 4 years ago . I am using the MVC5 for an web application. The web app runs in IIS7 or greater. In the Global.asax on application_start , the number of licenses will be set: protected void Application_Start() { try { MyApp.cNumberOfLicenses = COM.GetNumberOfLicenses(); } catch(Exception e) { // log exception // stop web site. } } If any expection

Automatically refresh ASP.NET Output Cache on expiry

…衆ロ難τιáo~ 提交于 2019-12-01 07:53:00
问题 I have a few expensive pages that I cache using ASP.NET output cache like so, [OutputCache(Duration=3600, VaryByParam = "none")] Obviously, the cache will expire after 3600 seconds (1 hour), and the next poor guy that happens to load that page will have to wait for the cache to be refreshed from the dabatase. My question is, how do I make the cache to be refreshed immediately on expiry? So that the next guy who happens to visit the page when the cache had just expired will not have to wait

Understanding async and await

纵饮孤独 提交于 2019-12-01 07:41:19
问题 I am trying to learn the details of MVC5 and I came across something that baffles me. In the accountController that comes by default with an MVC5 project with Individual Auth there is this line of code in the async Login and Register methods var result = await UserManager.CreateAsync(user, model.Password); I read here http://msdn.microsoft.com/en-us/library/hh191443.aspx that this is a normal practice, but I do not understand why you would ever use an asynchronous method and await in the same