Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "riaan"

Thanks.

I will upgrade to a newer version. Luckily my other dev machine and our production environment is on a higher version of SQL.

Thanks for the assistance.

Riaan

Hi,

Herewith my SQL version

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64) Mar 29 2009 10:11:52 Copyright (c) 1988-2008 Microsoft Corporation Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

Hi,

I've migrated the v4.1.1 code into my current application but encountered an Internal Server Error in the Host Admin Site. Thinking I made a mistake, I've downloaded the latest v4.1.1 code and ran it as a clean installation (without any modifications) and still encountered the Internal Server Error when signing into the Host Admin site.

Below traces of the web requests that gives the Internal Server Error, as well as a log extract, and the code portion I was able to trace where the exception occurs.

HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcVGVtcFxhc3BuZXQtY29yZVxzcmNcTXlDb21wYW55TmFtZS5BYnBaZXJvVGVtcGxhdGUuV2ViLk12Y1xhcGlcc2VydmljZXNcYXBwXFRlbmFudFxHZXRUZW5hbnRz?=
X-Powered-By: ASP.NET
Date: Tue, 27 Jun 2017 20:58:55 GMT

cf
{"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"An internal error occurred during your request!","details":null,"validationErrors":null},"unAuthorizedRequest":false,"__abp":true}
0
INFO  2017-06-27 22:24:54,089 [93   ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method MyCompany.AbpZeroTemplate.MultiTenancy.HostDashboard.HostDashboardAppService.GetDashboardStatisticsData (MyCompany.AbpZeroTemplate.Application) with arguments (MyCompany.AbpZeroTemplate.MultiTenancy.HostDashboard.Dto.GetDashboardDataInput) - ModelState is Valid
ERROR 2017-06-27 22:24:55,420 [102  ] Mvc.ExceptionHandling.AbpExceptionFilter - Incorrect syntax near 'OFFSET'.
Invalid usage of the option NEXT in the FETCH statement.
System.Data.SqlClient.SqlException: Incorrect syntax near 'OFFSET'.
Invalid usage of the option NEXT in the FETCH statement.
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__107_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- 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.EntityFrameworkCore.Storage.Internal.RelationalCommand.<ExecuteAsync>d__26.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.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<BufferlessMoveNext>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.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__6`2.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.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.&lt;MoveNext&gt;d__8.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.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.SelectAsyncEnumerable`2.SelectAsyncEnumerator.<MoveNext>d__4.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.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.SelectAsyncEnumerable`2.SelectAsyncEnumerator.&lt;MoveNext&gt;d__4.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.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.<MoveNext>d__5.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.EntityFrameworkCore.EntityFrameworkQueryableExtensions.<ToListAsync>d__129`1.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 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at MyCompany.AbpZeroTemplate.Authorization.Users.UserLinkAppService.<GetRecentlyUsedLinkedUsers>d__8.MoveNext() in MyCompany.AbpZeroTemplate.Application\Authorization\Users\UserLinkAppService.cs:line 95
--- 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.Internal.ObjectMethodExecutor.<CastToObject>d__38`1.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.Internal.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;d__27.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.Internal.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeNextExceptionFilterAsync&gt;d__24.MoveNext()
ClientConnectionId:f4add014-f6fe-4e6c-a301-971708f04b74
Error Number:102,State:1,Class:15

I was able to trace the exception to this section of the code:

public async Task&lt;GetNotificationsOutput&gt; GetUserNotifications(GetUserNotificationsInput input)
        {
            var totalCount = await _userNotificationManager.GetUserNotificationCountAsync(
                AbpSession.ToUserIdentifier(), input.State
                );

            var unreadCount = await _userNotificationManager.GetUserNotificationCountAsync(
                AbpSession.ToUserIdentifier(), UserNotificationState.Unread
                );

            var notifications = await _userNotificationManager.GetUserNotificationsAsync(
                AbpSession.ToUserIdentifier(), input.State, input.SkipCount, input.MaxResultCount
                );  // <-- This is where the exception occurs

            return new GetNotificationsOutput(totalCount, unreadCount, notifications);
        }

Any assistance would be appreciated

Thanks,

Riaan

Hi @ismcagdas,

The assistance you provided in solving the "INTERNAL SERVER ERROR" was invaluable and solved our 1st issue :)

Thanks for the feedback. I will look at the HTTPS redirects as suggested.

Kind Regards,

Riaan

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

Hi,

(Article [https://aspnetzero.com/Documents/Development-Guide-Core#authentication]) refers)

On a fast connection (PC) I'm able to get a token back when making a call to "https://mysite.xyz/api/TokenAuth/Authenticate" as per the above article.

On a slow connection (high latency) the response I get back is "Internal Server Error".

The slow connection is either when making the dynamic WebAPI call from our app running on a mobile phone or a shaped internet connection.

How/where can I increase the timeout in my ASPNETZERO app in order to allow for slow request/response?

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've tried to publish my ASPNETZERO-core application to my hosting provider with their provided settings file using VS2017. After the publishing of the website show success, when I try to access the site, I get the following error:

An error occurred while starting the application.

.NET Core X64 v4.1.1.0 | Microsoft.AspNetCore.Hosting version 1.1.2 | Microsoft Windows 6.3.9600

The hosting company provided me with an extract of an error file:

Application startup exception: System.ArgumentException: Keyword not supported: '"data source'.
   at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms)
   at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
   at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection()
   at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)
   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func`WebDep2 operation, Func`2 verifySucceeded, TState state)
   at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext](String connectionString, IDbContextResolver dbContextResolver)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext](Nullable`1 multiTenancySide)
   at MyApp.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action`1 contextAction) in C:\Users\User\Source\Repos\MyApp\src\MyApp.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 40
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Abp.AbpBootstrapper.Initialize()
   at Abp.AspNetCore.AbpApplicationBuilderExtensions.UseAbp(IApplicationBuilder app)
   at MyApp.MyApp.Web.Startup.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\Users\User\Source\Repos\MyApp\src\MyApp.Web.Mvc\Startup\Startup.cs:line 94
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Production
Content root path: h:\root\home\benborries-001\www\ppdev
Now listening on: http://localhost:10111
Application started. Press Ctrl+C to shut down.

I checked the appsettings.json file for the connection string and it appears to be in order:

{
  "ConnectionStrings": {
    "Default": "Server=HOSTINGPROVIDER.SQL;Database=HOSTING_DB;User Id=MY_HOSTING_USER;Password=THE_PASSWORD;"
  },
  "Abp": {
    "RedisCache": {
      "ConnectionString": "localhost",
      "DatabaseId": -1
    }
  },
  "App": {
    "WebSiteRootAddress": "http://{TENANCY_NAME}.dev.mydomain.xyz/"
  },
  "Authentication": {
    "Facebook": {
      "IsEnabled": "false",
      "AppId": "",
      "AppSecret": ""
    },
    "Google": {
      "IsEnabled": "false",
      "ClientId": "",
      "ClientSecret": ""
    },
    "Twitter": {
      "IsEnabled": "false",
      "ConsumerKey": "",
      "ConsumerSecret": ""
    },
    "Microsoft": {
      "IsEnabled": "false",
      "ConsumerKey": "",
      "ConsumerSecret": ""
    },
    "JwtBearer": {
      "IsEnabled": "true",
      "SecurityKey": "REMOVED",
      "Issuer": "REMOVED",
      "Audience": "REMOVED"
    },
    "OpenId": {
      "IsEnabled": "false",
      "Authority": "",
      "ClientId": "",
      "ClientSecret": ""
    }
  },
  "Recaptcha": {
    "SiteKey": "REMOVED",
    "SecretKey": "REMOVED"
  }
}

When I developed locally I used the MigratorApp to initialiase and seed the database, but on the hosting provider this appear not be be possible.

Any ideas to what the cause might be why I'm getting this?

I tried to run the app without and DB inistialiesd locally, but EFCore does not create the local DB for me. (The hosted DB, without the required tables, is already created by the hosting company)

Any assistance would be greatly appreciated.

Thx,

Riaan

Hi,

I see that we need to look at making use of the I​Equality​Comparer<​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();
Showing 11 to 20 of 24 entries