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

Activities of "sparkyjr"

I have been deploying our ASP.NET Zero project to Azure without problems for a while now. For last few days all deployments have started failing with error "SQLExpress database file auto-creation error: ", where it looks like the Azure system is trying to connect to a local database. Upon debugging it seems like this is happening only for authenticated pages. The login page shows up as expected, and login failures also happen. But as soon as authentication is successful, it seems a different DB is getting accessed.

Here is my current connection string in web.config

<add name="Default" connectionString="Data Source=xxx.database.windows.net,1433;Database=XYDB;User ID=xxx;Password=yyy;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" />

Looks like the system for some reason might be reverting to the LocalSqlServer connection string in machine.config. When I add the following

<remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString="Data Source=xxx.database.windows.net,1433;Database=XYDB;User ID=xxx;Password=yyy;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" />

The error now changes to "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'. "

Makes me wonder whether the ASPNet Zero is indeed using the ASP default role management? Is there a way I can disable it if it is not used? As this seems to be happening out of the blue, I am also thinking if this is because of some action on the Azure side. Any help is appreciated

Hi,

We have used Background Worker to send out emails every 24 hours. The problem is, the client never received any emails. We think that the application gets removed after certain time, and is not active on the server.

How do I keep the application alive and active all the time?

Thanks in advance!

Hi ,

This is my code

[HttpPost] [UnitOfWork] [DisableAuditing] public virtual async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "", string returnUrlHash = "") { CheckModelState();

        _unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant);

        var loginResult = await GetLoginResultAsync(loginModel.UsernameOrEmailAddress, loginModel.Password, loginModel.TenancyName);

        if (loginResult.User.ShouldChangePasswordOnNextLogin)
        {
            loginResult.User.SetNewPasswordResetCode();

            return Json(new MvcAjaxResponse
            {
                TargetUrl = Url.Action(
                    "ResetPassword",
                    new ResetPasswordViewModel
                    {
                        UserId = SimpleStringCipher.Encrypt(loginResult.User.Id.ToString()),
                        ResetCode = loginResult.User.PasswordResetCode
                    })
            });
        }

        if (loginResult.User.TenantId.HasValue)
        {
            var trMap = await _tennantRhythmMapReository.FirstOrDefaultAsync(x => x.TenantId == (int)loginResult.User.TenantId);

            HttpCookie cookie = new HttpCookie("TrackingRhythmType");
            cookie.Value = (await _trackingRhythmReository.FirstOrDefaultAsync(x => x.Id == trMap.TrackingRhythmId)).TrackingRhythmType;
            Response.SetCookie(cookie);

            HttpCookie cookieTenantName = new HttpCookie("TenantName");
            cookieTenantName.Value = loginResult.User.Tenant.TenancyName;
            Response.SetCookie(cookieTenantName);

            _backgroundWorkerManager.Add(_actualUpdationDueWorker);

            // sets PersonalizedCaptionsCookie in PersonalizedCaptionsService.
            //await _personalizedCaptionService.SetPersonalizedCaptionsCookie(loginResult.User.TenantId);
        }
        else
        {
            var c = new HttpCookie("TenantName");
            c.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(c);
        }

        await SignInAsync(loginResult.User, loginResult.Identity, loginModel.RememberMe);

        if (string.IsNullOrWhiteSpace(returnUrl))
        {
            returnUrl = Url.Action("Index", "Application");
        }

        if (!string.IsNullOrWhiteSpace(returnUrlHash))
        {
            returnUrl = returnUrl + returnUrlHash;
        }

        return Json(new MvcAjaxResponse { TargetUrl = returnUrl });
    }

<cite>hikalkan: </cite> It's saved as null if the entity is created when user did not login (so, we don't know userid).

Thanks for your reply!

But, that's not the case. User is logged in. We update a record using either InsertOrUpdateAsync or UpdateAsync method. The LastModifierUserId gets updated with correct UserId, but, the CreatorUserId becomes NULL. That's a big issue for us. Could you please check and tell us why does this happen?

Thanks in advance!

Thanks for your reply!

We are using Background Worker and not Background Job. We need to fire a method periodically to check if some data in some tables has been updated or not. If it has not been updated, we are sending out an email to the users informing them about the pending updates.

Now, if I add/register the worker in the pre-initialize method in the project module file, then, it will be difficult for us to fetch the data, because, we don't get the TenantId there. So, we have added/registered the worker in the LogIn() method. The worker calls an Application Service and does everything for us.

Hope this explanation helps!

Thanks in advance!

Hi,

What all are the possible cases when the CreatorUserId goes as null?

Thank you for your reply!

But when I login with two different Tenant users , two different tabs of the same browser why does UserManager.AbpSession.TenantId show me previous TenantId (from first tab of the browser) and not the latest one? And hence the Repositories and Services bring me data for the previous Tenant (from first tab of the browser) and not the current one.

Also, I am using Background Worker to send out emails (every 24hours) with some data, specific to the Tenant. I couldn't add the worker in the pre-initialize method of the project module file. I need a TenantId, so, I was forced to add it in the Login method, and call an Application Service, where I need TenantId. Now, because of the issue explained in the paragraph above, I am getting wrong data.

Am I doing anything wrong here? From where can I get the correct TenantId?

Thanks in advance!

Hi,

When testing for multiple Tenants the TenantId is getting cached in AbpSession. Just to recreate this scenario you could check AccountController, and try logging with different Tenants.

Hi,

I am trying to inject a service through the constructor in WebViewPageBase.cs lying in Web Project -> Views -> WebViewPageBase but its not allowing. Does Dependency Injection through the constructor not work for WebViewPageBase.cs class?

Thanking you in advance.

That worked. I will have a look at the UOW document. Thank you so much hikalkan!

Showing 61 to 70 of 71 entries