Hi.
Thanks. It appears the http rewrite rule in the web.config caused the issue.
Any best practice aspnetzero recommendation for implementing https only on an aspnetzero site? Apart from setting the site directory in the appsettings.json file to force https only, for mvc as well as static files?
Thx
Hi ismcagdas,
I checked the logs and found the following during the api/TokenAuth/Authenticate process.
INFO 2017-05-26 13:35:36,584 [37 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 POST http://app.my.url/api/TokenAuth/Authenticate application/json 68
DEBUG 2017-05-26 13:35:36,600 [37 ] NetCore.StaticFiles.StaticFileMiddleware - POST requests are not supported
DEBUG 2017-05-26 13:35:36,600 [37 ] osoft.AspNetCore.Routing.Tree.TreeRouter - Request successfully matched the route with name '(null)' and template 'api/TokenAuth/Authenticate'.
DEBUG 2017-05-26 13:35:36,600 [37 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action Company.MyApp.Web.Controllers.TokenAuthController.Authenticate (MyCompany.MyApp.Web.Core)
INFO 2017-05-26 13:35:36,600 [37 ] idateAntiforgeryTokenAuthorizationFilter - Antiforgery token validation failed. The required antiforgery header value "X-XSRF-TOKEN" is not present.
Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: The required antiforgery header value "X-XSRF-TOKEN" is not present.
at Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.<ValidateRequestAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ValidateAntiforgeryTokenAuthorizationFilter.<OnAuthorizationAsync>d__3.MoveNext()
INFO 2017-05-26 13:35:36,600 [37 ] ore.Mvc.Internal.ControllerActionInvoker - Authorization failed for the request at filter 'Abp.AspNetCore.Mvc.Antiforgery.AbpAutoValidateAntiforgeryTokenAuthorizationFilter'.
INFO 2017-05-26 13:35:36,600 [37 ] icrosoft.AspNetCore.Mvc.StatusCodeResult - Executing HttpStatusCodeResult, setting HTTP status code 400
Note that I do have the HTTPS rewrite rule for the .netcore app in the web.config on in order to redirect all calls made to the website and dynamic wbapi endpoints to HTTPS instead of http. Would this have an effect?
The web.config as follow:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyCompany.MyApp.Web.Mvc.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
and the appsettings.json as follow:
{
"ConnectionStrings": {
"Default": "sqlconnectionstring"
},
"App": {
"WebSiteRootAddress": "http://app.my.url"
},
"Authentication": {
"JwtBearer": {
"IsEnabled": "true",
"SecurityKey": "MyApp_8DEB2BA534E24D56",
"Issuer": "MyApp",
"Audience": "MyApp"
},
}
}
Thanks,
Riaan
<cite>ismcagdas: </cite> Hi,
Your first problem is related to connection string as you know. Before fixing that, you need to create your db using migrations.
We only have migrator tool for that but I couldn't understand why you couldn't use it. If you have access to SQL DB from your computer, you can run migrator on your PC.
Hi,
Thanks. I managed to get this working. The issue was that the DB tables was not created after the deploy as you suggested.
What I did was to change the MigratorTool's datasource to the website's DB (hosted) and run the migrator, which created the tables for me and resolved our issue.
Thanks.
Hi,
I see that we need to look at making use of the IEqualityComparer<T> Interface because of this being a ASPNETCOREZERO project and Contains() is not part of ASPNET CORE.
I will investigate the use of IEqualityComparere<T> for string case insensitive compares a bit later, but found the following solution (although not as elegant) to be working in the meantime for case-insensitive filtering:
var foodNotes = _foodNoteRepository
.GetAll()
.WhereIf(
!input.Filter.IsNullOrEmpty(),
p => p.Title.ToLower().Contains(input.Filter.ToLower()) ||
p.Detail.ToLower().Contains(input.Filter.ToLower()))
.OrderBy(p => p.Title)
.ThenBy(p => p.CreationTime)
.ToList();
Hi,
Thanks. Since there is no production DB yet, the easiest way was to follow your suggestion to rename the tablename in code, and drop the local DBs and run the migrator again.
Worked like a charm. :)
Hi,
I don't get any build errors but I do get the red squiggly lines when viewing the abp.d.ts file.
[attachment=0:3mmh5obq]abp.d.ts.png[/attachment:3mmh5obq]
I have updated to TypeScript (2.1.4) for Visual Studio 2015 [https://www.microsoft.com/en-us/download/details.aspx?id=48593], but still the red lines appear.
Any ideas on how to get rid of them, or should I just ignore them in my solution?