Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > ASP.NET
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 12.01.2022, 16:21   #1
rita616
Пользователь
 
Регистрация: 19.12.2019
Сообщений: 69
По умолчанию HomeController

Здравствуйте. Мне нужна помощь с кодом. Приложение развернуто на одном порту, но есть редирект на другой порт. Вот нужно мне убрать этот редирект, но не могу найти где. Подскажите, пожалуйста.
Код:
namespace TFOMS_WebApp.Controllers
{
    public class HomeController : Controller
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private UnitOfWork uow = UnitOfWork.getInstance();
        public ActionResult Index()
        {
            return View();
        }

        [Authorize]
        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        [Authorize]
        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        [Authorize(Roles = "EXPERT")]
        public ActionResult GetDictionaries(int? Page)
        {
            GetDictionariesViewModel model = new GetDictionariesViewModel();

            if (this.Session[model.SessionLabel] != null)
            {
                int skip = Page.HasValue ? Page.Value - 1 : 0;

                model = (GetDictionariesViewModel)this.Session[model.SessionLabel];

                model.Rows = model.Data.Skip(skip * model.RowsPerPage).Take(model.RowsPerPage).ToList();
            }
            else
            {
                model.DicNames = uow.repositoryMEE.DbDictionaryNames;
            }

            log.Info(string.Format("Open view. Data: {0} entries", model.Data.Count));
            return View(model);
        }

        [HttpPost]
        [Authorize(Roles = "EXPERT")]
        [ValidateAntiForgeryToken]
        public ActionResult GetDictionaries(int? Page, GetDictionariesViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            model.DicNames = uow.repositoryMEE.DbDictionaryNames;
            var dbdic = uow.repositoryMEE.GetDictionary(model.Dictionary);
            
            model.Title = dbdic.Name;
            model.Data = dbdic.RowList;
            model.Rows = dbdic.RowList.Take(model.RowsPerPage).ToList();
            model.TotalCount = dbdic.RowList.Count;


            if ((this.Session[model.SessionLabel]) != null)
            {
                this.Session.Remove(model.SessionLabel);
            }
            this.Session.Add(model.SessionLabel, model);

            if (dbdic.RowList.Count > 0)
            {
                ViewBag.MessageColour = "success";
                ViewBag.StrongMessage = "Готово!";
                ViewBag.Message = "Результат:" + dbdic.RowList.Count;
            }
            else
            {
                ViewBag.MessageColour = "warning";
                ViewBag.StrongMessage = "Готово!";
                ViewBag.Message = "Для заданных критериев записей нет";
            }

            log.Info(string.Format("Requested data. Dic: {0}. Data: {1} entries",
                model.Dictionary,
                model.Data.Count));

            return View(model);
        }

        [HttpPost]
        [Authorize(Roles = "EXPERT")]
        [ValidateAntiForgeryToken]
        public FileResult SaveDictionaries()
        {
            GetDictionariesViewModel model = new GetDictionariesViewModel();

            if (this.Session[model.SessionLabel] != null)
            {
                GetDictionariesViewModel savedmodel = new GetDictionariesViewModel();

                savedmodel = (GetDictionariesViewModel)this.Session[savedmodel.SessionLabel];

                ExcelWrapper exw = new ExcelWrapper();
                var mem = new MemoryStream();
                
                exw.SaveDefaultTable(savedmodel.Data, savedmodel.Title, 
                    new Dictionary<string, string>() { {"Code", "Код" },  {"Description", "Описание" }, {"ValidTo", "Действует до" } },
                    null,  mem);

                log.Info(string.Format("Saved data. Dic: {0}. Data: {1} entries",
                    savedmodel.Dictionary,
                    savedmodel.Data.Count));

                mem.Position = 0;
                return File(mem, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Uri.EscapeDataString(savedmodel.Title) + ".xlsx");
            }
            else
                return null;

        }
        
        public ActionResult Reconstr()
        {
            return View();
        }
    }
}
rita616 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск