asp.net-core-mvc

Is ViewData the new standard over ViewBag for ASP.Net 5 (core)?

心已入冬 提交于 2019-12-03 08:15:00
问题 I have noticed that in all the examples and tutorials on ASP.Net 5 (core) I have seen from Microsoft and the default Web Application template in VS 2015 use @ViewData["XXX"] instead of @ViewBag.XXX . Is this the, now, recommended way of passing data up from the controller instead of ViewBag ? I know that ViewBag is a wrapper for ViewData but in the old tutorials (ASP.NET 4.5) they use ViewBag . If they are now encouraging developers to use ViewData why the change? 回答1: Both are still valid.

ASP.Net MVC Angular 2 Final

女生的网名这么多〃 提交于 2019-12-03 07:28:20
问题 Has anyone tried Angular 2 RC Final with ASP.Net MVC? I am having trouble with configuring Angular 2 RC 6 with ASP.Net MVC, till beta 17 everything was working fine. The package.json with below configuration doesn't seems to be working: "dependencies": { "@angular/common": "2.0.0-rc.6", "@angular/compiler": "2.0.0-rc.6", "@angular/core": "2.0.0-rc.6", "@angular/forms": "0.3.0", "@angular/http": "2.0.0-rc.6", "@angular/platform-browser": "2.0.0-rc.6", "@angular/platform-browser-dynamic": "2.0

ServiceFilter and TypeFilter - what is the difference in injection those filters?

大城市里の小女人 提交于 2019-12-03 07:22:25
ServiceFilter we must register in Startup.cs. TypeFilter is injected by Microsoft.Extensions.DependencyInjection.ObjectFactory, we don't need register that filter. So when we should use ServiceFilter and when TypeFilter ? According to Pro ASP.NET Core MVC 2 book. Chapter 19: Filters , page # 615 When using the TypeFilter attribute, a new instance of the filter class is created for every request. This is the same behavior as applying a filter directly as an attribute, except that the TypeFilter attribute allows a filter class to declare dependencies that are resolved through the service

WS-Federation sign-in Asp.NET 5 MVC 6 ADFS

孤街醉人 提交于 2019-12-03 07:08:24
Hello so I've been trying to achieve WS-Fed SSO on my MVC6 web application, I've read a bit on authentification and all to identify my requirements. I have to use WsFederationAuth so no oauth nor saml protocol would work for me. Edit : After @Pinpoint suggestion I tried to use owin middleware to achieve the connection, but I will use the full framework DNX451 rather than DNXCore but it's something while waiting for ws-fed to be supported by Vnext. Pinpoint adapter extension : public static class AppBuilderExtensions { #if !DNXCORE50 public static IApplicationBuilder UseOwinAppBuilder(this

Build: Cannot find name Promise - Visual Studio 2015 w/ MVC6 and Angular 2

谁说我不能喝 提交于 2019-12-03 06:46:22
First of all: I've checked these: https://github.com/angular/angular/issues/7052 https://github.com/angular/angular/issues/4902 Typescript cannot find name 'Promise' despite using ECMAScript 6 how to use es6-promises with typescript? Visual Studio Code: Cannot find name angular? How to get rid of Angular2 / TypeScript errors on Cannot find map, Promise ... when targeting -es5 And many many many more. Been banging my head for 2 days now. And yes: I have referenced in my boot.ts file (or bootstrap file): ///<reference path="../node_modules/angular2/typings/browser.d.ts"/> Now, to the problem: I

Specific JSON settings per controller on ASP.NET MVC 6

末鹿安然 提交于 2019-12-03 06:38:19
I need specific JSON settings per controller in my ASP.NET MVC 6 webApi. I found this sample that works (I hope !) for MVC 5 : Force CamelCase on ASP.NET WebAPI Per Controller using System; using System.Linq; using System.Web.Http.Controllers; using System.Net.Http.Formatting; using Newtonsoft.Json.Serialization; public class CamelCaseControllerConfigAttribute : Attribute, IControllerConfiguration { public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) { var formatter = controllerSettings.Formatters.OfType<JsonMediaTypeFormatter>()

mvc6 unauthorized results in redirect instead

白昼怎懂夜的黑 提交于 2019-12-03 06:34:50
I have been trying to prevent the redirect when I return an NotAuthorized IActionResult from a Controller, but regardless of my attempts, NotAuthorized gets translated to a Redirect. I have tried what is mentioned here (same issue, using older beta framework, I use 1.0.0-rc1-final). I do not have the Notifications namespace (has been removed in rc1-final). This is my Login Controller: [HttpPost] [AllowAnonymous] public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Email,

Can one use Reportviewer Control in ASP.net Core

情到浓时终转凉″ 提交于 2019-12-03 06:26:10
I want to make use of the Reporting Services ReportViewer control in an ASP.NET Core MVC project. The solution as proposed in other answers it to add a webform to the project. However since ASP.NET Core doesn't support webforms I cannot add the control to a webform. Is there any other workaround that might possibly assist me in using the ReportViewer control in an ASP.NET Core Web application? Update 2019 I have ReportViewer working on ASP.NET Core on Windows, and most features (not PDF and Images/PowerPoint) also work on ASP.NET Core on Linux. There's still some bugs to weed out, though. You

ASP.NET Core configuration reloadOnChange with IOptionsSnapshot still not responsive

亡梦爱人 提交于 2019-12-03 06:18:50
I'm using ASP.NET Core 2.0 and I have configuration code like this in the Main method: public static void Main(string[] args) { var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{environment ?? "Production"}.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .AddCommandLine(args) .Build(); } I have the reloadOnChang e set to true, and in my controller I am

Using enum for dropdown list in ASP.NET MVC Core

让人想犯罪 __ 提交于 2019-12-03 06:11:55
问题 I'm trying to create a dropdown list with an enum property in ASP.NET MVC Core using the tag helper in a Razor view: Here is the model: public class PersonalMember : Member { [Required, Display(Name = "First Name")] public string FirstName { get; set; } [Required, Display(Name = "Last Name")] public string LastName { get; set; } [EnumDataType(typeof(Gender))] public Gender GenderType { get; set; } } public enum Gender { Male = 1, Female = 2 } Here is part of a form in the view: <div class=