asp.net-mvc-5

SignInManager.ExternalSignInAsync with Facebook always returns failure

非 Y 不嫁゛ 提交于 2020-01-06 02:41:54
问题 Google+ works, but Facebook always returns a failure. When I examine loginInfo it shows that authenticated = true. This is the code in Statup.Auth.cs - I included the Google+ code which works. public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext

Multiple IHttpActionResults GET's within a single ApiController fail

假装没事ソ 提交于 2020-01-05 23:05:53
问题 I am playing with WebApi2 and came across an odd issue. I have updated the default ValuesController to use IHttpActionResult like public class ValuesController : ApiController { // GET api/values [HttpGet] public IHttpActionResult Get() { return Ok(new string[] { "value1", "value2" }); } // GET api/values/get2 [HttpGet] public IHttpActionResult Get2() { return Ok(new string[] { "value1", "value2" }); } When I try call Get() within postman I get an error { "Message": "An error has occurred.",

How to add using statement in mvc 5 to all views

倾然丶 夕夏残阳落幕 提交于 2020-01-05 12:12:07
问题 There are many examples of adding a using statement for all views in web.config for prior versions, but I have not found one for MVC 5. Can someone give me an example? 回答1: Locate Web.config in the Views folder. Find the namespace section. It will already have namespaces for Mvc. Add the desired namespace: <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization"/> <add namespace=

How to add using statement in mvc 5 to all views

拟墨画扇 提交于 2020-01-05 12:11:11
问题 There are many examples of adding a using statement for all views in web.config for prior versions, but I have not found one for MVC 5. Can someone give me an example? 回答1: Locate Web.config in the Views folder. Find the namespace section. It will already have namespaces for Mvc. Add the desired namespace: <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization"/> <add namespace=

Extend IsAjaxRequest() to include fetch api requests

十年热恋 提交于 2020-01-05 08:39:14
问题 I am currently building a site using MVC5 and I need to serve different content when an ajax request is made. Usually we use jQuery and make an ajax request using $.ajax , but recently we have moved towards using the fetch api. However, requests using the fetch api aren't registering with MVC as ajax requests so the wrong template is being used. I have thought about making my own is ajax request extension but not sure what header to check for: public static bool IsAjaxOrFetchRequest(this

IIS LocalSystem only will run my exe

时光总嘲笑我的痴心妄想 提交于 2020-01-05 08:36:07
问题 IIS on WindowsServer 2012, ASP.NET MVC It is very bad to run an IIS 8.5 site as LocalSystem, but that is the only way I can get this exe to run. I need to be able to have the site run this: var pdfProcess = new Process(); pdfProcess.StartInfo.FileName = SomeExeInProgramFiles; pdfProcess.StartInfo.Arguments = stuff; pdfProcess.StartInfo.WorkingDirectory = docPath; //!!!!This is really important!!!!! pdfProcess.Start(); Running windows 2012, how can I let my AppPoolIdentity site run the above

Adding properties to IdentityUser doesn't create the correct migration

流过昼夜 提交于 2020-01-05 07:45:21
问题 I've followed the tutorial here: Customizing profile information in ASP.NET Identity in VS 2013 templates And did exactly what's written there, except for that my new property is a string named 'TaxId'. Surprisingly, when I did the "Add-Migration" part, the migration file came up empty: namespace Mvc5Test.Migrations { using System; using System.Data.Entity.Migrations; public partial class TaxId : DbMigration { public override void Up() { } public override void Down() { } } } Any idea why did

trigger modal popup in mvc form with a button click

依然范特西╮ 提交于 2020-01-05 07:22:27
问题 I have this view in mvc in which I display details for a model. The modal popup was working fine until I didn't put it in form block. Now its only posting back instead of displaying the popup. This is the view I have: @using App.Portal.WebUI.Controllers @using MvcPaging @model IPagedList<App.Models.Device> @{ ViewBag.Title = "Manage Devices"; } <h2>Manage Devices</h2> @Html.ActionLink("Add New Device", "Manage", "Handhelds", new { @class = "editUser btn btn-info" }) <button id="showInactive"

'RouteCollection' doesn't contain a definition for 'MapMvcAttributeRoutes'

余生颓废 提交于 2020-01-05 05:25:07
问题 I try to use attribute based routing. But when i try the following snippet to activate attribute based routing i get the following error message: RouteCollection' doesn't contain a definition for 'MapMvcAttributeRoutes This is my code: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); //Attribute Routing } } These are the references: using System; using System.Web.Mvc; using

How to send bearer token to views in ASP NET MVC 5?

廉价感情. 提交于 2020-01-05 04:41:31
问题 I have a .NET MVC and WEB API project. I want to call the WEB API controllers from javascript but I didn't find a way to send the token to my views. I want to add the bearer token in Viewbag variable, using the below code: protected override void OnActionExecuting(ActionExecutingContext filterContext) { //GetBearerToken doesn't exists ViewBag.BearerToken = Request.GetOwinContext().GetBearerToken(); } In _Layout.cshtml , I added the folowing code to set Authorization header for all ajax