Hello.
I have downloaded:
- Project Type (required) - ASP.NET CORE & Angular
- Project Version (required) - v5.0.4 (latest)
- Framework (required): - .NET Framework 4.6.1
For back-end - I opened solution(.\aspnet-core\Sperse.Platform.Web.sln) under VisualStudio 15.4.4 and changed in appsettings.json IdentityServer IsEnabled --> "true" than ran migrator and than started project Sperse.Platform.Web.Host under IIS Express.
For front-end - I restored packages via yarn and run npm start - after successful webpack compilation I opened a browser and went to localhost:4200 and after that I received an exception on back-end:
System.InvalidOperationException
Message:
You must either set Authority or IntrospectionEndpoint
StackTrace:
at Microsoft.AspNetCore.Builder.OAuth2IntrospectionOptions.Validate()
at IdentityModel.AspNetCore.OAuth2Introspection.PostConfigureOAuth2IntrospectionOptions.PostConfigure(String name, OAuth2IntrospectionOptions options)
at Microsoft.Extensions.Options.OptionsFactory1.Create(String name) at Microsoft.Extensions.Options.OptionsMonitor
1.<>c__DisplayClass10_0.<Get>b__0()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Here is HTTP Raw Request data:
GET http://localhost:22742/AbpUserConfiguration/GetAll HTTP/1.1 Host: localhost:22742 Connection: keep-alive Pragma: no-cache Origin: http://localhost:4200 Abp.TenantId: null Authorization: Bearer null Content-Type: application/json Accept: application/json, text/javascript, /; q=0.01 Cache-Control: no-cache X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36 .AspNetCore.Culture: c=null|uic=null Expires: Sat, 01 Jan 2000 00:00:00 GMT Referer: http://localhost:4200/ Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9
HTTP/1.1 500 Internal Server Error Server: Kestrel X-SourceFiles: =?UTF-8?B?RDpcc291cmNlc1xBc3AuTmV0IFplcm9cQXNwLk5ldCBDb3JlICYgQW5ndWxhclw1LjAuNFxORVQgRnJhbWV3b3JrIDQuNi4xXFBsYXRmb3JtMlxQbGF0Zm9ybVxhc3BuZXQtY29yZVxzcmNcU3BlcnNlLlBsYXRmb3JtLldlYi5Ib3N0XEFicFVzZXJDb25maWd1cmF0aW9uXEdldEFsbA==?= X-Powered-By: ASP.NET Date: Mon, 18 Dec 2017 16:25:34 GMT Content-Length: 0
7 Answer(s)
-
0
The problem in UI part:
.\angular\src\AppPreBootstrap.ts
private static getUserConfiguration(callback: () => void): JQueryPromise<any> { const cookieLangValue = abp.utils.getCookieValue('Abp.Localization.CultureName'); return abp.ajax({ url: AppConsts.remoteServiceBaseUrl + '/AbpUserConfiguration/GetAll', method: 'GET', headers: { Authorization: 'Bearer ' + abp.auth.getToken(), <---------------Without null Bearer it works---------------------------------------------------- '.AspNetCore.Culture': ('c=' + cookieLangValue + '|uic=' + cookieLangValue), 'Abp.TenantId': abp.multiTenancy.getTenantIdCookie() } }).done(result => { $.extend(true, abp, result);
HTTP raw request data:
GET <a class="postlink" href="http://localhost:22742/AbpUserConfiguration/GetAll">http://localhost:22742/AbpUserConfiguration/GetAll</a> HTTP/1.1 Host: localhost:22742 Connection: keep-alive Pragma: no-cache Origin: <a class="postlink" href="http://localhost:4200">http://localhost:4200</a> Abp.TenantId: null User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36 Content-Type: application/json Accept: application/json, text/javascript, /; q=0.01 Cache-Control: no-cache X-Requested-With: XMLHttpRequest .AspNetCore.Culture: c=null|uic=null Expires: Sat, 01 Jan 2000 00:00:00 GMT Referer: <a class="postlink" href="http://localhost:4200/account/login">http://localhost:4200/account/login</a> Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9
HTTP/1.1 200 OK Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 Server: Kestrel Access-Control-Allow-Origin: * X-SourceFiles: =?UTF-8?B?RDpcc291cmNlc1xBc3AuTmV0IFplcm9cQXNwLk5ldCBDb3JlICYgQW5ndWxhclw1LjAuNFxORVQgRnJhbWV3b3JrIDQuNi4xXFBsYXRmb3JtMlxQbGF0Zm9ybVxhc3BuZXQtY29yZVxzcmNcU3BlcnNlLlBsYXRmb3JtLldlYi5Ib3N0XEFicFVzZXJDb25maWd1cmF0aW9uXEdldEFsbA==?= X-Powered-By: ASP.NET Date: Mon, 18 Dec 2017 16:43:43 GMT
e3e {"result":{"multiTenancy":{"isEnabled":true,"sides":{"host":2,"tenant":1}},"session":{"userId":null,"tenantId":null,"impersonatorUserId":null,"impersonatorTenantId":null,"multiTenancySide":2},"localization":{"currentCulture":{"name":"en","displayName":"English"},"languages":[{"name":"de","displayName":"Deutsch","icon":"famfamfam-flags de","isDefault":false,"isDisabled":false,"isRightToLeft":false},{"name":"en","displayName":"English","icon":"famfamfam-flags gb","isDefault":true,"isDisabled":false,"isRightToLeft":false},{"name":"es-MX","displayName":"Español (México)","icon":"famfamfam-flags mx","isDefault":false,"isDisabled":false,"isRightToLeft":false},{"name":"es","displayName":"Español (Spanish)","icon":"famfamfam-flags es","isDefault":false,"isDisabled":false,"isRightToLeft":false},{"name":"fr","displayName":"Français","icon":"famfamfam-flags fr","isDefault":false,"isDisabled":false,"isRightToLeft":false},{"name":"it","displayName":"Italiano","icon":"famfamfam-flags it","isDefault":false,"isDisabled":false,"isRightToLeft":false},{"name":"pt-BR","displayName":"Português (Brasil)","icon":"famfamfam-flags ................ ................ ...............
-
0
hi
AbpUserConfiguration/GetAll method is being request 2 times. First one is when you land the page and second one after you login. So in your first GetAll() without authentication; you don't need bearer token, it shouldn't be there in the header. For the second request (after you successfully login) bearer token must be a long string. When you get null token? before login or after login?
-
0
Hi. I got null token before login.
-
0
As I understand, is this behaviour(asp.net zero angular UI sends Authorization: Bearer null in a request to API) is a bug?
-
0
Hi @SperseDev,
Can you create an issue on github and let us test this case ? There might be a bug.
-
0
Yes.
-
0
hi
Checkout the related commit that fixes the issue.
<a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/commit/05d955996844b3c1ab9c0f9eb72644dd8748fd4f">https://github.com/aspnetzero/aspnet-ze ... dd8748fd4f</a>