Quantcast
Channel: ASP.NET Core
Viewing all 9386 articles
Browse latest View live

Nuget for ClientAssertionCertificate class in asp.net core to connect to AAD throught ADAL

$
0
0

Hi ,

We are trying to connect to AAD to get access token/jwt token using Certificate instead of using Client Secret in Asp.Net Core application . But Microsoft.IdentityModel.Clients.ActiveDirectory nuget  ( version: 3.10.305231913 ) has only IClientAssertionCertificate interface . There is no concrete class for this interface. 

Do we have any nuget package for this interface implementation?

Thanks


Localization using vs 2017

$
0
0

Greetings,

I'm trying to add localization on .Net Core 1.1 using Visual Studio 2017.

Every time I try to localize from an injected HtmlLocalizer in my view, it returns the global resource value (SharedResources.resx).

I tried with the IViewLocalizer with resx files with the same name as the view without success.

I created a folder Resources, added SharedResources.cs, SharedResources.en.resx, SharedResources.fr.resx and SharedResources.resx in it.

Here is my code :

Startup.cs

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddLocalization(options => options.ResourcesPath = "Resources");
            // Add framework services.
            services.AddMvc()
                .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
                .AddDataAnnotationsLocalization();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            var supportedCultures = new []
            {
                new CultureInfo("fr"),
                new CultureInfo("en"),
                new CultureInfo("en-US")
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("fr"),
                // Formatting numbers, dates, etc.
                SupportedCultures = supportedCultures,
                // UI strings that we have localized.
                SupportedUICultures = supportedCultures
            });

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }


View (About.cshtml)

@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@inject IHtmlLocalizer<SharedResources> SharedHtmlLocalizer

@{
    ViewData["Title"] = "About";
}<h2>@ViewData["Title"].</h2><h3>@ViewData["Message"]</h3><p>@SharedHtmlLocalizer["myRes"]</p><p>Use this area to provide additional information.</p>

@await Html.PartialAsync("_SelectLanguagePartial")

SharedResources.cs

namespace TestResx
{
    public class SharedResources
    {
    }
}



Resources folder :

-Resources/
-- SharedResources.cs
-- SharedResources.en.resx
-- SharedResources.fr.resx
-- SharedResources.resx

Is there something I'm doing wrong ? I can't see what's the problem here..

Thanks a lot

Error with latest .net Core and VS2015

$
0
0

I have installed the latest .net Core Runtime (1.1.1) and SDK (1.0.1) versions and I am getting the following error:

The following error occurred attempting to run the project model server process (1.0.1).  Unable to start the process.  No executable found matching comment "dotnet-projectmodel-server".  and it goes on from there ...

Things had been working correctly with a previous version of .net and VS2015.

I tried uninstalling both the runtime and sdk, but I am still getting the same error.

Please let me know if you need additional info to figure out how I am messing up.

project.json

{
  "version": "1.0.0-*","buildOptions": {"emitEntryPoint": true
  },"dependencies": {"Microsoft.NETCore.App": {"type": "platform","version": "1.1.1"
    }
  },"frameworks": {"netcoreapp1.0": {"imports": "dnxcore50"
    }
  }
}
global.json

{
  "projects": [ "src", "test" ],"sdk": {"version": "1.0.1"
  }
}



Thanks!

Modelbinding a List stopped working when moving from .net core 1.0 to .net core 1.1 .cshtml contains a form with a foreach loop

$
0
0

Hi all,

When upgrading to 1.1 my modelbinding from a form stopped working

public class test {

public int id {get;set;}

public string name {get;set;}

}

[HttpGet]

public async Task<IActionResult> doIt()

{

List<test> model = new List<test>();

test atest = new test();

atest.id = 1;

atest.name="First";

model.Add(atest);

atest = new test();

atest.id=2;

atest.name="Second";

model.Add(atest);

return View(model)

}

[HttpPost]

public async Task<IActionResult> doIt(List<test> model)

{

if(ModelState.IsValid)

{

//model.Count() is always Zero after upgrade to 1.1 :-)

}

}

//doIt.cshtml

@model List<test>

<form asp-action="doIt" method="post">

@foreach(test item in Model)

{

<label asp-for="@Model.First().id"></label>

<input type="hidden" asp-for="@item.id" value="@item.id" />

<label asp-for="@Model.First().name"></label>

<input type="hidden" asp-for="@item.name" value="@item.name" />
<button id="btnConfirm" type="submit" class="btn btn-info">Go On</button>

</form>
}

Re-indexing an array

$
0
0

Hi guys,

     I'm working with some data that I'm currently getting back from my models as Dbset.ToList(). The data contains dates, similar to this:

{id: 1, date: 2017-03-01, attribute1: red, attribute2: 10 }, 

{id: 2, date: 2017-03-02, attribute1: green, attribute2: 20 }, 

{id: 3, date: 2017-03-03, attribute1: red, attribute2: 10 }, 

{id: 4, date: 2017-03-03, attribute1: green, attribute2: 5 }

I want to be able to access my 'attribute2' by referring to the date and 'attribute1' ..... so for example accessing x["2017-03-03"]["green"] should give 5.

Is there some nicely packaged, entity framework-esque way of transforming my list in this way? or should I do I just create it manually?

.... Ultimately, I just need to display the data in a table with all dates (including those without data) to be displayed as row headers and 'attribute1' to be displayed as column headers. Any suggestions on how I should approach this?

ASPNet.Core - Adding Session

$
0
0

Hi,

I'm trying to allow ASPNet Core Application(using EF6) the ability to use Session to store User Information. 

Following the instructions on this link:

https://www.exceptionnotfound.net/finding-and-using-asp-net-session-in-core-1-0/

Project.json - dependency section:

  "dependencies": {
    "AutoMapper": "5.2.0",
    "EntityFramework": "6.1.3",
    "EntityFramework.CodeFirstStoreFunctions": "1.0.0",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",                
    "Microsoft.AspNet.Session": "1.0.0-rc1-final",                   /* new added */
    "Microsoft.AspNet.Http": "1.0.0-rc1-final",                       /* new added */
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },


Startup.cs

        public void ConfigureServices(IServiceCollection services)        
        {             // Add framework services.            
                services.AddApplicationInsightsTelemetry(Configuration);            
                 services.AddScoped<SVPData>(_ => new SVPData(Configuration.GetConnectionString("DefaultConnection")));            
                 services.AddMvc();
                 services.AddMemoryCache();            
                 services.AddSession(options =>            
                              {                 options.IdleTimeout = TimeSpan.FromMinutes(15);                
                                                options.CookieName = ".MyCoreApp";             });        
                               } 

The last line errors :

Error CS0121 The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.SessionServiceCollectionExtensions.AddSession(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action<Microsoft.AspNetCore.Builder.SessionOptions>)' and 'Microsoft.Extensions.DependencyInjection.SessionServiceCollectionExtensions.AddSession(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action<Microsoft.AspNet.Session.SessionOptions>)' 

If I try to change the version of the lines(as suggested in the link below):

Project.json

    "Microsoft.AspNet.Session": "1.0.0",                   /* new added */
    "Microsoft.AspNet.Http": "1.0.0",                       /* new added */

http://stackoverflow.com/questions/38327196/asp-net-mvc-core-the-call-is-ambiguous-between-the-following-methods-or-properti

Output tab displays:

log  : Restore failed in 6853ms.

Errors in C:\Deployed\SVPWebApp\src\SVPWebApp\SVPWebApp.xproj    
Unable to resolve 'Microsoft.AspNet.Session (>= 1.0.0)' for '.NETFramework,Version=v4.5.2'.    
Unable to resolve 'Microsoft.AspNet.Http (>= 1.0.0)' for '.NETFramework,Version=v4.5.2'.

I appreciate your input!

Thanks,

tinac99

Convert .Net Framework 4.6.1 Console App to .Net Core 1.1

$
0
0

I've tried searching but can't find out how to convert a .Net Framework 4.6.1 console application to .Net Core 1.1.  I am using VS2017.  I was able to create a new .Net Core 1.1 console application and copy all of my .cs files and that seems to work.  I was wondering if there was a way to convert the solution directly.  In the properties window for my original 4.6.1 application in VS2017, there is not a .Net Core option for target framework (even though I can create a .Net Core application from scratch).

Thanks!

Coded UI Testing VS2017

$
0
0

Hi,

I am working on Dotnet core project and recently upgraded to VS2017. I would like to perfom coded ui testing using vs2017.but i did not found any useful links or materials available in any forums. can some one please suggest me how to take it forward.

Thanks

Dev


New job -- Preparing, looking for a language equivalent

$
0
0

Hiya,

I'm switching to cshart/mvc/core for a new job and I was hoping to find a framework equivalent.

In the other framework, i have a hugely important feature to me : modular class w/ dependent js/img/css assets that sort of 'live' inside the class folder -->


1. "Outside" the WebApp, modularized, somewhere on my computer, I have the following single class folder container/structure (Please note: I'm not looking for a Video Player Class this is just an example):

--> VideoPlayerClass (Folder - inside are the following files/folders)
          ---> VideoPlayerClass.lang (File - Class w/ following 3 lines of code)
                    this.getAssetManager().publish() //this pushes all files from Assets to the public root in a clever one time way
                    this.addScriptFile(this.dynamicallyCreatedPath+'/Assets/video.js')
                    this.addCssFile(this.dynamicallyCreatedPath+'/Assets/video.css')
          ---> Assets (Folder)
                    ---> video.js (File)
                    ---> video.css (File)
          ---> Views (Folder)
                    ---> main.lang (File with view logic)
                              this.write("<div id='video'></div>")

2. Then, in the view of the actual web app:

          this.write(this.loadExtension("Extensions.VideoPlayerClass.lang"))


3. The final HTML output:

          the following is injected into the head:

          <link rel="stylesheet" type="text/css" href="/assets/7bde39ab-HashValue/video.css" />
          <script type="text/javascript" src="/assets/7bde39ab-HashValue/video.js"></script>

          and then written to the body:

          <div id='video'></div>



4. This way, 

- I don't worry about manually copying asset files to public root
- I just write the class once, the asset files live with the class and the framework sees that I'm using the class for the first time in the app, pushes the files to the public asset folder and i'm ready.

Can someone point me to a similar concept in Csharp/Asp.net/Core?

Thanks!
- Bryan

ASP.NET Core 1.1 on IIS returning empty response body for errors

$
0
0

Is there a way to fix this or have I somehow missed a patch that fixes this?

I have an ASP.NET Core 1.1 app that's returning empty response bodies from my exception filter for my 409 error codes. The rub is that I can't reproduce this problem locally or on my dev staging server which uses the same image as our QA server. QA Server is Windows 2012. All hosted on EC2. I have verified that the problem happens even on local machine (altered hosts. file, not by using "localhost"). 

This is my Main in Startup.cs

		public static void Main()
		{
			var cwd = Directory.GetCurrentDirectory();
			var web = "public";

			var host = new WebHostBuilder()
					.UseContentRoot(Directory.GetCurrentDirectory())
					.UseWebRoot(web)
					.UseKestrel()
					.UseIISIntegration()
					.UseStartup<Startup>()
					.Build();

			host.Run();
		}

This is my Exception filter. (We use the GenericHttpException when we want to pass up stuff like the 409 for duplicate entity inserts.)

public class UnicornExceptionFilter : IExceptionFilter
    {
        public async void OnException(ExceptionContext context)
        {
            HttpStatusCode status = HttpStatusCode.InternalServerError;
            String message = String.Empty;




            var exceptionType = context.Exception.GetType();
            if (exceptionType == typeof(NotFoundException))
            {
                message = context.Exception.Message;
                status = HttpStatusCode.NotFound;
            }
            if (exceptionType == typeof(BadRequestException))
            {
                message = context.Exception.Message;
                status = HttpStatusCode.BadRequest;
            }
            if (exceptionType == typeof(GenericHttpException))
            {
                message = context.Exception.Message;
                status = (context.Exception as GenericHttpException).HttpStatusCode;
            }
            else
            {
                message = context.Exception.Message;
            }

            HttpResponse response = context.HttpContext.Response;
            response.StatusCode = (int)status;
            response.ContentType = "application/json";
            var err = message ;

            await response.WriteAsync(JsonConvert.SerializeObject(new { message= err }));

        }
    }

I have already tried adding HttpErrors Passthrough to web.config as well as CustomErrors off. These steps did not resolve the issue. I've also tried messing with ExceptionHandled as described in this thread https://github.com/aspnet/Mvc/issues/5594 with no success. Also note that this is for our RESTful endpoints and not for MVC Razor views. 

In our local Windows 10 IIS Express and Dev staging Windows Server 2012 IIS, the response body still returns. Our QA/staging environment has the same base image as Dev staging and uses the same publish script and release configuration.  Thanks

Using ASP.NET Core MVC app tutorial with Authentication

$
0
0

Hello,

I'm using Visual Studio 2017 Community to follow this tutorial: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/ and I included "Individual User Accounts Authentication" when I created the project.

 I got to the "Adding a Model" chapter and when I did the "Update the database" using the command prompt, it gave this error:

"More than one DbContext was found. Specify which one to use. Use the '-Context' parameter for PowerShell commands and the '--context' parameter for dotnet commands.".

So I used these commands to make it work: 

dotnet restore
dotnet ef migrations  add Initial -c MvcMovieContext
dotnet ef database update -c MvcMovieContext

I saved the solution just before running these command line commands.

I finished the "Adding a Model" chapter.

When I run the project, it runs fine and the user authentication works, except that there are two databases with the project.  One for the movie data and the other for the account authentication.

Is there someway to make these two databases into one database and have it so that the user has to login before using the movie database?

I would like to do that before I continue on to the "Working with SQL Server LocalDB" chapter.

Any help would be gratefully appreciated.

Thanks,
Tony

.Net Core Model Localization How to be the key from Resource File

$
0
0

Hello,

I have a question about DataAnnotations Localization for Models in .NET Core 1.1 : I can't understand how to put the Key and Value in the Resource File .

For Example I have a Title Annotation in Model and I have a resource file named: Models.AdminViewModels.DepartmentViewModel.fr-FR.resx  .

I tried to insert a keys like : ErrorMessage, Title, TitleRequired, etc, but nothing is working .

namespace PL.Models.AdminViewModels{publicclassDepartmentViewModel{[Required(ErrorMessage="Title Required")]publicstringTitle{get;set;}}}

You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral ??

$
0
0

Hi Devs,

first of all I want to to say that I really liked the RC1 release, but didn't expect the MS team to radically change everything in RC2? 👎 Why call it RC while you changed practically everything in the RC2 release? My whole project doesn't work and i'm spending days to convert everything to RC2 and my project is still not working. I want to host everything under IIS, so cross platform does not interest me and want to use also .NET Framework libraries. One of them is ReflectSoftware.Insight for debugging and logging purposes.
I've added the package through Nuget, but when I add _ri.SendDebug("test"); to my code, I get the following compiler error:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. FFSNXG..NETCoreApp,Version=v1.0

How can I make this work, so I can use some of our .NET Framework 4.xx libs in my project?
How can i add this lib so libs such as SendGrid & ReflectInsight works? Thanks very much for your help!

My Project file is:

`{
"userSecretsId": "aspnet-FFSNXG-xxxxxxxxxx",

"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"NXGDAL": "1.0.0-*",
"Microsoft.Framework.Runtime.Abstractions": "1.0.0-beta5",
"Microsoft.AspNetCore.Session": "1.0.0-rc2-final",
"ReflectSoftware.Insight": "5.6.0",
"Sendgrid": "6.3.4"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
"Microsoft.Extensions.SecretManager.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8",
"net452"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"gcServer": true
},

"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},

"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
`

Receive Invalid Token From Twitter on Azure but locahost is ok

$
0
0

Hi,

I'm using Linq2Twitter plugin to link my site to Twitter, users are able to authenticate on localhost but once deployed to Azure, Twitter most likely provides invalid tokens....

I have described the problem here: http://stackoverflow.com/questions/42708752/linq2twitter-callback-working-on-localhost-but-not-azure

But after investigation I can see that the callback url is identical (the hostname is different indeed due to localhost/live site) but Twitter API would provide different token/verifier.

I have my live site url set as https://sarahah.com as  the website in dev.twitter.com

Thank you

How to get the notifications in the css template dashboard page ?

$
0
0

I am making an online  exam software , in  which i need to get a  css dashboard, after the student registers and logs in.After I download the template, I need to  show the notifications, for the same in the dashboard page. How to get that ?


google claim based authentication

$
0
0

Hi guys,

I want to know google claim based authentication.(For Example : Full User Name / Country Code / Profile Image URL...and etc..)

Does guys have demo code or related blog article?

User.Identity.IsAuthenticated always false

$
0
0

Hi,

I start to test Identity with web api in .net core. I done a method that get the current user, but I obtain a bad request because this User.Identity.IsAuthenticated is always false.

I don't undestand because. The token hascorrectlybeencreated.

I call the web api with Angular 2 .

public async Task<string> GetCurrentUserId()
        {
            // if the user is not authenticated, throw an exception
            if (!User.Identity.IsAuthenticated)
                throw new NotSupportedException();

            var info = await SignInManager.GetExternalLoginInfoAsync();
            if (info == null)
                // internal provider
                return User.FindFirst(ClaimTypes.NameIdentifier).Value;
            else
            {
                // external provider
                var user = await UserManager.FindByLoginAsync(
                    info.LoginProvider,
                    info.ProviderKey);
                if (user == null) throw new NotSupportedException();
                return user.Id;
            }
        }

someone can help me?

BR

Building Navigation Rules

$
0
0

I'm going to use the default ASP.NET Core web application _Layout.cshtml as my example. It creates the following navigation bar:

<ul class="nav navbar-nav"><li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li><li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li><li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li></ul>

Imagine there is a form on each tab and we want the user to complete the forms in order (Home > About > Contact) without skipping over an "incomplete" tab. However, if the user had completed Home and About, they would be able to skip from Home to Contact.

My thought is to create a persistent stored string on application load which has the "tab" state (X for incomplete, C for complete). So initially, TabState would be `XXX` and would update as needed.

My question is, how can I prevent/allow navigation depending on this TabState? Is this something that I can do in the controllers or would I need to do this logic somewhere else?

Consume wcf service from asp.net core Credentials not found

$
0
0

I have added a service reference with Visual studio WCF connected service.

When i try to consume i receive the exception that the credentials are not found.

I´ve been able to consume this service in asp.net mvc but to make this work i made a trick to overriding the headers in the request:

 

 public class AgendasWs2 : CatalogosAgendasWS_A
    {
        protected override System.Net.WebRequest GetWebRequest(Uri uri)
        {

            HttpWebRequest request;
            request = (HttpWebRequest)base.GetWebRequest(uri);

            if (PreAuthenticate)
            {
                NetworkCredential networkCredentials = Credentials.GetCredential(uri, "Basic");
                if (networkCredentials != null)
                {

                    byte[] credentialBuffer = new UTF8Encoding().GetBytes(networkCredentials.UserName + ":" + networkCredentials.Password);

                    request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);
                }
                else
                {
                    throw new ApplicationException("No network credentials");
                }
            }
            return request;
        }
    }

As you can see i override the headers before sendind the request.

The service has a Preemptive authentication type

I dont have any idea of making this in asp.net core.

Any help :)

ArgumentException: The 'ClientId' option must be provided

$
0
0

Attempting to do 3rd party authentication using Facebook.  This used to work under .Net Core 1.0, but I just upgraded to VS2017 and .Net Core 1.1.

Complete error is:

ArgumentException: The 'ClientId' option must be provided.

Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<TOptions> options)

ArgumentException: The 'ClientId' option must be provided.

Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<TOptions> options)

Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<FacebookOptions> options)

Microsoft.Extensions.Internal.ActivatorUtilities+ConstructorMatcher.CreateInstance(IServiceProvider provider)

Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)

Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)

Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()

Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

I noted that .AddUserSecrets() deprecated so I updated to .AddUserSecrets<Startup>();

.csproj is as follows:

<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>netcoreapp1.1</TargetFramework><PreserveCompilationContext>true</PreserveCompilationContext><AssemblyName>SP_Reports</AssemblyName><OutputType>Exe</OutputType><PackageId>SP_Reports</PackageId><UserSecretsId>aspnet-SP_Reports-fe51af8e-b15e-40b8-a748-9260b3185259</UserSecretsId><PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback><RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion></PropertyGroup><ItemGroup><None Update="wwwroot\**\*;Views\**\*;Areas\**\Views"><CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory></None></ItemGroup><ItemGroup><ProjectReference Include="..\SP_Common_Classes\SP_Common_Classes.csproj" /></ItemGroup><ItemGroup><PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /><PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" /><PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" /><PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /></ItemGroup><Target Name="PrepublishScript" BeforeTargets="PrepareForPublish"><Exec Command="bower install" /><Exec Command="dotnet bundle" /></Target><ItemGroup><DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" /><DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" /></ItemGroup></Project>

Any suggestions??

Viewing all 9386 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>