Base solution for your next web application

Activities of "gep13"

We have an odd situation, and I am not sure where to start with debugging this, so I am hoping that someone can shed some light on the problem.

We have released a version of the website, and installed it on a test machine, and everything is working as expected.

Since then, we have made some changes to the website, including adding some database tables, and changing schema etc.

If we run Migrator on the already installed instance, all the database changes are applied correctly.

However, if I run the same Migrator on a new instance of the website, not all migrations are applied. It seems to miss deploying the last 5 migrations.

Has anyone seen anything like this? There are no errors reported during the process of deploying the new database.

Thanks Gary

Can you also confirm where the list of Time Zones is coming from? I notice in version 6.2.1 there has been a change in the way the list is formatted compared to another version we were using (where it also included location information, for example, London.

@ismcagdas does the TimeZoneHelper simply wrap the TimeZoneConverter? That is what I am using in the code above?

I can confirm that the value in the AbpSetttings table for that User is indeed:

Greenland Standard Time

Hello,

I am hoping that someone can point me in the right direction regarding how timezones work in ASP.NET Zero. Firstly, let me explain what I have done...

I am using 6.2.1 of the template, and I have made the following modifications:

Added the following into my Startup.cs:

Clock.Provider = ClockProviders.Utc;

I have then changed the Date Time Format strings in the Users/index.js to the following:

 return moment(lastLoginTime).format('D MMM YYYY HH:mm:ss');

i.e. to include the Time portion.

So the first question, with the changes that I have made above, I would expect that all DateTimes stored in the database would be treated as UTC times, and as such, any display of these times, or export to Excel, to account for this. I can see this in action if I change the currently logged in user to another time zone (for example Greenland, which is three hours away from UTC)

In the above screenshot, everything works. The UTC date in the database is correctly displayed in the currently configured local timezone.

However, if I now do the following, things no longer do what I expect...

I change the creation date time to be on the 24th October 2018. On this day, Britain was in Daylight Savings mode, and as a result, we were 1 hour away from UTC. If at this point in time I created a user (which is what I am trying to simulate by making this change), the date stored in the database should have been offset by one hour. As a result, when I export/display the values, I would expect a 1 hour offset. This isn't happening, as you can see in this screenshot:

Are my expectations here invalid?

Assuming that all times are stored in UTC, and the site takes into account daylight savings, when exporting/displaying the Last Login DateTime, I would expect there to be a 1 hour offset. Can you please confirm if there is another setting that I need to enable to get the expected output?

Thanks

Gary

@aaron that will work! Thank you for the suggestion.

As you will know, we get a generated zip file with "our" copy of the template for each release of ASPNETZERO. I have a branch in my repository specifically for this purpose. In that branch I have the original 5.2.0 template (where we started), and then I took the extracted contents of thr 5.3.0 template and put them into this branch, committing any modiciations to the files. I then merged this branch into my main branch, so that I can get all the changes between 5.2.0 and 5.3.0 into my "live" version of the site.

This resulted in some merge conflicts, as I had made some changes to the template that conflicted with other modifications that had been done, but this is to be expected.

Now, if I were to use the same approach for the 5.4.0 release (which is where this problem was resolved by deleting those files I wouldn't have "seen" the deletion of those files. Since extracting the contents of the 5.4.0 template onto the existing 5.3.0 files would have meant that those two files were still there. And since the projects are usng the new csproj format, those files will remain as part of the project.

Does that make sense?

Am I using the correct approach? If there is a better way to do this, I am all ears. I can't "follow" all the changes on your main repository, since it is in a templated form, and as a result, I can't apply each and every commit onto my "live" version of the site.

Ok, looks like I have finally been able to get to the bottom of this! :-)

In version 5.3.0 of the ASPNETZERO template there were actually two TagHelpers, as can be seen here:

https://github.com/aspnetzero/aspnet-zero-core/tree/v5.3.0/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/TagHelpers

This is important, as I was only editing one of the TagHelpers to the latest version, as I didn't actually know that the other one was required. As a result, the first TagHelper was actually doing exactly the right thing, but the second TagHelper which seems to run second due to the name of the file, was actually undoing what had been done before.

In version 5.4.0, it seems like the other files for the TagHelper were deleted see this commit:

https://github.com/aspnetzero/aspnet-zero-core/commit/9e6557412381305f9c1311777986c729e34476d0#diff-264fc5c693926ba92c268b4dcca1c714

With this change in place, i.e. only having one set of TagHelpers, which contain the most recent code, everything seems to be working as expected.

This sort of change does illustrate the complexity in how to move between versions of the template, as I don't see how this change would have been caught in the recommended way of updating the template to the latest version.

@ryancyq I had the same thought as you before starting this thread, but I checked that the AddIfNotContains was actually adding something, and you can see in this screenshot:

That the src attribute is there, and it contains the min.js version of the URL, however, what gets rendered to the client is as I have mentioned before, the normal js URL.

@alirizaadiyahsi the final code that I updated to is the following:

using System.Text.Encodings.Web;
using Abp.Collections.Extensions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Caching.Memory;

namespace RandomNameHere.TagHelpers
{
    [HtmlTargetElement("script")]
    public class AbpScriptSrcTagHelper : ScriptTagHelper
    {
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (output.Attributes["abp-ignore-src-modification"] != null && output.Attributes["abp-ignore-src-modification"].Value.ToString() == "true")
            {
                base.Process(context, output);
                return;
            }

            string srcKey;
            if (output.Attributes["abp-src"] != null)
            {
                srcKey = "abp-src";
            }
            else if (output.Attributes["src"] != null)
            {
                srcKey = "src";
            }
            else
            {
                base.Process(context, output);
                return;
            }

            if (output.Attributes[srcKey].Value.ToString().StartsWith("~"))
            {
                base.Process(context, output);
                return;
            }

            if (output.Attributes[srcKey].Value is HtmlString ||
                output.Attributes[srcKey].Value is string)
            {
                var href = output.Attributes[srcKey].Value.ToString();
                if (href.StartsWith("~"))
                {
                    return;
                }

                var basePath = ViewContext.HttpContext.Request.PathBase.HasValue
                    ? ViewContext.HttpContext.Request.PathBase.Value
                    : string.Empty;

                if (!HostingEnvironment.IsDevelopment() && !href.Contains(".min.js"))
                {
                    href = href.Replace(".js", ".min.js");
                }

                Src = basePath + href;
                context.AllAttributes.AddIfNotContains(new TagHelperAttribute("src", Src));
            }

            base.Process(context, output);
        }

        public AbpScriptSrcTagHelper(
            IHostingEnvironment hostingEnvironment,
            IMemoryCache cache,
            HtmlEncoder htmlEncoder,
            JavaScriptEncoder javaScriptEncoder,
            IUrlHelperFactory urlHelperFactory
        ) : base(hostingEnvironment, cache, htmlEncoder, javaScriptEncoder, urlHelperFactory)
        {
        }
    }
}

Which I took from here:

https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/TagHelpers/AbpZeroTemplateScriptSrcTagHelper.cs

Are there any other changes in the most recent version, outside of this single file that I would need to incorporate to get this to work?

Out of interest, what is the most recent version?

Would it be possible to jump on a shared session so that I can "show" you what I am seeing, as I think that might be the quickest way to establish why this isn't working.

@ismcagdas we are currently using aspnetzero 5.3.0. However, I noticed that there were quite a few changes in the AbpZeroTemplateScriptSrcTagHelper.cs, so I updated my copy to use the latest code from the GitHub Repository.

However, both versions of the class resulted in the same thing, i.e. the min.js extension not being rendered to the browser.

That is why I was wondering if there was any other code that I have overlooked, or configuration that needs to be changed, in order for it to work correctly.

Based on your last response, are you able to replicate this problem? I would be available for a shared support session, where you can see my screen, if that would help, as I would really like to get to the bottom of this.

Showing 11 to 20 of 43 entries