如何加快我的申请 [英] How to speed up my application

查看:125
本文介绍了如何加快我的申请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好弗伦茨,
Iam非常困惑,以加快加载主页和中间视图的速度.该应用程序是由其他人开发的,并分配给我以解决运行缓慢的问题.
它由microsoft.AspNet.Identity程序集组成,因此在代码中实现了许多异步和等待方法.所以这是缓慢的原因.请建议加快应用程序的速度.这是一个带有实体框架mysql数据库的mvc项目,对这些技术不太熟悉.

我尝试过的事情:

代码有点像

Hello frenz,
Iam very much confused to speed up the application in loading home page and also in loading intermediate views. The application was developed by some one else and was assigned me to fix the issues of slow running.
it consists of microsoft.AspNet.Identity assembly, so many async and await methods were implemented in code. So is this the reason for slow.please suggest to speed up the application. it is an mvc project with entity framework mysql database and am not much familiar with these technologies.

What I have tried:

the code is some thing like

 public async Task<actionresult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //string uname = "vinay", pwd = "kavayah";
                    var user = await UserManager.FindAsync(model.UserName, model.Password);

                    if (user != null)
                    {
                        await SignInAsync(user, model.RememberMe);
                        //return RedirectToLocal(returnUrl);                        
                        return RedirectToAction("CampaignList", "Campaign");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid username or password.");
                    }
                  
                }
}




 public async Task<actionresult> CampaignList()
        {
            try
            {
                ApplicationUser user = null;
                string userid = User.Identity.GetUserId();
                user = await UserManager.FindByIdAsync(userid);
                if (user.CampaignList.Count() > 0)
                {
                    foreach (var item in user.CampaignList)
                    {
                        string Csv = "";
                        item.KeyWordList = item.KeyWordList.Where(x => x.Status).ToList();
                        if (item.KeyWordList.Count() > 0)
                        {
                            foreach (var item1 in item.KeyWordList)
                            {

                                Csv += item1.KeyWordName + ",";
                            }
                        }

                        item.Keyword_Csv = Csv.TrimEnd(',');
                    }

                    return View(user.CampaignList);
                }
                return RedirectToAction("AddCampaign", "Campaign");
            }

推荐答案

这里没有什么可以提高速度的.您发布的代码中的所有异步调用都没有用,因为登录是一个同步过程.问题不在于此代码,而在于其他地方.您将必须对此应用程序进行概要分析,以找出瓶颈所在,找出瓶颈的原因,然后重新编写代码或网站依赖于其进行改善的其他任何代码.
There isn''t anything here to make faster. All the async calls in the code you posted are just useless because this a login is a synchronous process. The problems are not with this code but elsewhere. You''re going to have to profile this application to figure out where the bottlenecks are, figure out why it''s a bottleneck and then rework the code or whatever else the site is dependent on to improve it.


这篇关于如何加快我的申请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆