asp.net-core-2.0

Is is possible to make SEO friendly Url's in ASP.NET Core like this one

有些话、适合烂在心里 提交于 2019-12-11 03:54:36
问题 I wanted to ask you guys if is it possible, to make some routing like this for my project /{action}/{title} ? I was wondering if that is possible, does this url has to be a primary key too? Since there is no ID passed to know which blog post is this. Thank you. 回答1: You can do this quite easily with attribute routing: [Route("blogs")] public class BlogController { [AcceptVerbs("GET", "HEAD", Route = "{slug}")] public IActionResult View(string slug) { } } This maps all requests to /blogs

GenerateChangePhoneNumberTokenAsync on ASP.NET Core 2.0

懵懂的女人 提交于 2019-12-11 02:35:51
问题 Trying to use this code on ASP.NET Core 2.0 ApplicationUser MyUser = await _userManager.FindByNameAsync(model.Email); var Code = await _userManager.GenerateChangePhoneNumberTokenAsync(MyUser, model.MobileNumber); Results for variable "Code" is this instead of 6 digits. CfDJ8Kjv6NuVfg5GkZ9ZEJRMBG2BxkZ4fnbwTfkq5335ft3Lm0sCl7uaRXFce+uDMtXC8wgdoiocyXV4nGlBz25tkbZr4JvZ6/1gk6EenJKmkq2of3XXfK/xMWE/M2aqmkz9OJpOe75Wz+xlmgq

ASP.NET Core 2.0 authentication based on host name

可紊 提交于 2019-12-11 02:34:30
问题 I would say that classic ASP.NET Core 2.0 application with authentication consists of adding desired authentication service in ConfigureServices method in the Startup.cs file: services.AddAuthentication().AddFacebook(facebookOptions => { facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"]; facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }); This is fine as long as the authentication configuration is known during the time when

Multiple authenticaion schemes in asp .net core 2.0

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:27:47
问题 I need to support two authentication types in ASP.NET Core 2.0 MVC application: AddIdentityServerAuthentication AddOpenIdConnect It was very easy in ASP.NET Core 1.0 version. But in version 2.0 version syntax changed. This is my code: services.AddAuthentication(o => { o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; o.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; o.DefaultAuthenticateScheme = OpenIdConnectDefaults.AuthenticationScheme; })

Testing an application inside docker container in VSTS

橙三吉。 提交于 2019-12-11 02:23:55
问题 I'm trying to test an ASP. NET Core 2 dockerized application in VSTS. It is set up inside the docker container via docker-compose. The tests make requests via addresses stored in config (or taken from environment variables, if set). Right now, the build is set up like this: Run compose command to restore and publish the app. Run compose to create and run docker containers. Run a bash script (explained below). Run tests. First of all, I found out that I can't use http://localhost:port inside

Angular 6 with ASP.NET Core, internal CMD not working properly

偶尔善良 提交于 2019-12-11 02:08:10
问题 Hello I have Angular 6 project with ASP.NET Core 2.0. backend. Working in Visual Studio. No server side rendering, just SPA. When i run my project (F5), ng serve command automatically called by .Net, code below. Produces new command line window, but it seems like the styles (line rewriting, text progress bars,...) not working. app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); Text stops rendering, but

Implement authorization on Fields using GraphQL.NET and ASP.NET Core 2

为君一笑 提交于 2019-12-11 01:43:25
问题 I have a existing REST API developed using ASP.NET WEB API 2 where the authorization is handled by storing all the controller name and action method details in a xml file. WebAPIAuthorization.xml: <?xml version="1.0" encoding="utf-8" ?> <WebApiAuthorizationSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <WebApiControllerAuthorizationSettings> <WebApiControllerAuthorizationSetting> <ControlerName>Profile</ControlerName>

Asp.net core 2.0 AutoMapper IValueResolver dependency injection

天大地大妈咪最大 提交于 2019-12-11 01:39:01
问题 I have tried most of the examples in the Google Results, Stackoverflow and in AutoMapper. But was not able to get the IValueResolverdependancy injection to work. I have below service public class StorageService : IStorageService { private readonly BlobServiceSettings _blobServiceSettings; public StorageService(IOptions<BlobServiceSettings> blobServiceSettings) { _blobServiceSettings = blobServiceSettings.Value; } // some methods I need } This is my profile public class MappingProfile :

Db Resource Authorization in EF Core

泄露秘密 提交于 2019-12-11 01:25:29
问题 I'm writing a Rest API Framework, I'd like to create a db authorization context. The context takes in a role resolver and uses that to filter the default set. Base on a set of rules. In my First Attempt I thought maybe I could apply default filters to the entity sets to prohibit access to certain resources public class AuthorizationContext : DbContext { protected IConstraintResolver _constraintResolver; public AuthorizationContext(IConstraintResolver constraintResolver) { this.

Azure App Services will not start after App Insights upgrade to 2.5

半城伤御伤魂 提交于 2019-12-11 00:24:15
问题 I have a repository that uses application insights to log information about our services running in asp.net. We have some ASP.NET Core 2.0 sites along with some full framework asp.net 4 applications. With the release of application insights 2.5, we get support for live streaming in core sites so I upgraded all packages in the solution to use latest 2.5. Then I built the branch and deployed it via VSTS build and release and I noticed my live streaming was working great. Then, I released the