Good Morning, I created some pages of errors and some modal by css, but this one giving error when trying to visualize the modal, instead of loading it the modal it loads a 404 error
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using macpartner.Models;
namespace macpartner.Controllers
{
public class ErrorController : Controller
{
private MacPartnerContext db = new MacPartnerContext();
// GET: Error
public ActionResult Index(int error = 0)
{
switch (error)
{
case 500:
ViewBag.Imagem = "https://i.imgur.com/JUtjbnQ.png";
break;
case 404:
ViewBag.Imagem = "https://i.imgur.com/6hW4WwF.png";
break;
default:
ViewBag.Imagem = "https://i.imgur.com/nBbSpyD.png";
break;
}
return View("~/views/error/_ErrorPage.cshtml");
}
}
}
controller modal:
using macpartner.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace macpartner.Controllers
{
public class DashboardsController : Controller
{
macpartner.Models.MacPartnerContext db = new Models.MacPartnerContext();
// GET: Dashboards
public ActionResult Index()
{
ViewBag.Parceiros = db.Users.Where(u => u.Parceiro == true).ToList();
if (ViewBag.Parceiros.Count > 0)
{
ViewBag.ParceirosCount = ViewBag.Parceiros.Count;
}
else
{
ViewBag.ParceirosCount = 0;
}
ViewBag.Leads = db.Leads.ToList();
if (ViewBag.Leads.Count > 0)
{
ViewBag.LeadsCount = ViewBag.Leads.Count;
}
else
{
ViewBag.LeadsCount = 0;
}
ViewBag.LeadsConvertidos = db.Leads.Where(l => l.status == "Negócio Fechado!").ToList();
if (ViewBag.LeadsConvertidos.Count > 0)
{
ViewBag.LeadsConvertidosCount = ViewBag.LeadsConvertidos.Count;
}
else
{
ViewBag.LeadsConvertidosCount = 0;
}
ViewBag.LeadsPendentes = db.Leads.Where(l => l.status == "Pendente").ToList();
if (ViewBag.LeadsPendentes.Count > 0)
{
ViewBag.LeadsPendentesCount = ViewBag.LeadsPendentes.Count;
}
else
{
ViewBag.LeadsPendentesCount = 0;
}
ViewBag.LeadsProcesso = db.Leads.Where(l => l.status != "Pendente" && l.status != "Negócio Fechado!" && l.status != "Proposta Recusada").ToList();
if (ViewBag.LeadsProcesso.Count > 0)
{
ViewBag.LeadsProcessoCount = ViewBag.LeadsProcesso.Count;
}
else
{
ViewBag.LeadsProcessoCount = 0;
}
ViewBag.LeadsFinalizados = db.Leads.Where(l => l.status == "Negócio Fechado!" || l.status == "Proposta Recusada").ToList();
if (ViewBag.LeadsFinalizados.Count > 0)
{
ViewBag.LeadsFinalizadosCount = ViewBag.LeadsFinalizados.Count;
}
else
{
ViewBag.LeadsFinalizadosCount = 0;
}
ViewBag.Consultores = db.Users.Where(u => u.Vendedor == true).ToList();
ViewBag.DataFinalDefault = DateTime.Today.ToShortDateString();
ViewBag.DataInicialDefault = "01" + DateTime.Today.ToShortDateString().Substring(2, 8);
ViewBag.DataDiaSemana = DateTime.Today.DayOfWeek;
ViewBag.DataInicioSemana = "";
Dictionary<int, int> ParceirosDict = new Dictionary<int, int>();
foreach (var p in ViewBag.Parceiros)
{
ParceirosDict.Add(p.UserId, p.Leads.Count);
}
var ParceirosDictSorted = ParceirosDict.OrderByDescending(key => key.Value).ToList();
var ParceiroOuroId = ParceirosDictSorted[0].Key;
var ParceiroPrataId = ParceirosDictSorted[1].Key;
var ParceiroBronzeId = ParceirosDictSorted[2].Key;
ViewBag.ParceiroOuroNome = db.Users.Find(ParceiroOuroId).FirstName;
ViewBag.ParceiroPrataNome = db.Users.Find(ParceiroPrataId).FirstName;
ViewBag.ParceiroBronzeNome = db.Users.Find(ParceiroBronzeId).FirstName;
ViewBag.ParceiroOuroTotal = ParceirosDictSorted[0].Value;
ViewBag.ParceiroPrataTotal = ParceirosDictSorted[1].Value;
ViewBag.ParceiroBronzeTotal = ParceirosDictSorted[2].Value;
return View();
}
// GET: Dashboards/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: Dashboards/Create
public ActionResult Create()
{
return View();
}
// POST: Dashboards/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Dashboards/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: Dashboards/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
// GET: Dashboards/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: Dashboards/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
public ActionResult Filtro(int consultorId, string dInicio, string dFim)
{
if (consultorId != 0)
{
//Filtrando parceiros cadastrados pelo consultor
ViewBag.Parceiros = db.Users.Where(u => u.ConsultorId == consultorId).ToList();
}
else
{
//Filtrando parceiros cadastrados pelo consultor
ViewBag.Parceiros = db.Users.Where(u=> u.Parceiro == true).ToList();
}
if (ViewBag.Parceiros.Count > 0)
{
ViewBag.ParceirosCount = ViewBag.Parceiros.Count;
}
else
{
ViewBag.ParceirosCount = 0;
}
//Filtrando Leads dos parceiros do consultor
ViewBag.Leads = db.Leads.ToList();
List<Lead> leadsByConsultorId = new List<Lead>();
List<Lead> leadsConvertidosByConsultorId = new List<Lead>();
List<Lead> leadsProcessoByConsultorId = new List<Lead>();
List<Lead> leadsPendentesByConsultorId = new List<Lead>();
List<Lead> leadsFinalizadosByConsultorId = new List<Lead>();
foreach (var lead in ViewBag.Leads)
{
var parceiro = db.Users.Find(lead.UserId);
//Check se o lead é da rede do consultor
if ((parceiro.ConsultorId == consultorId || consultorId == 0) && (DateTime.Parse(lead.data.ToShortDateString()) >= DateTime.Parse(dInicio) && DateTime.Parse(lead.data.ToShortDateString()) <= DateTime.Parse(dFim)))
{
leadsByConsultorId.Add(lead);
//Check se o lead foi convertido
if (lead.status == "Negócio Fechado!")
{
leadsConvertidosByConsultorId.Add(lead);
}
//Check se o lead está em processo
if (lead.status != "Negócio Fechado!" && lead.status != "Proposta Recusada" && lead.status != "Pendente")
{
leadsProcessoByConsultorId.Add(lead);
}
//Check se o lead está pendente
if (lead.status == "Pendente")
{
leadsPendentesByConsultorId.Add(lead);
}
//Check se o lead está finalizado
if (lead.status == "Negócio Fechado!" || lead.status == "Proposta Recusada")
{
leadsFinalizadosByConsultorId.Add(lead);
}
}
}
ViewBag.Leads = leadsByConsultorId;
ViewBag.LeadsConvertidos = leadsConvertidosByConsultorId;
ViewBag.LeadsPendentes = leadsPendentesByConsultorId;
ViewBag.LeadsProcesso = leadsProcessoByConsultorId;
ViewBag.LeadsFinalizados = leadsFinalizadosByConsultorId;
//count de Leads
if (ViewBag.Leads.Count > 0)
{
ViewBag.LeadsCount = ViewBag.Leads.Count;
}
else
{
ViewBag.LeadsCount = 0;
}
//count de Leads Convertidos
if (ViewBag.LeadsConvertidos.Count > 0)
{
ViewBag.LeadsConvertidosCount = ViewBag.LeadsConvertidos.Count;
}
else
{
ViewBag.LeadsConvertidosCount = 0;
}
//count de Leads Pendentes
if (ViewBag.LeadsPendentes.Count > 0)
{
ViewBag.LeadsPendentesCount = ViewBag.LeadsPendentes.Count;
}
else
{
ViewBag.LeadsPendentesCount = 0;
}
//count de Leads em Processo
if (ViewBag.LeadsProcesso.Count > 0)
{
ViewBag.LeadsProcessoCount = ViewBag.LeadsProcesso.Count;
}
else
{
ViewBag.LeadsProcessoCount = 0;
}
//count de Leads Finalizados
if (ViewBag.LeadsFinalizados.Count > 0)
{
ViewBag.LeadsFinalizadosCount = ViewBag.LeadsFinalizados.Count;
}
else
{
ViewBag.LeadsFinalizadosCount = 0;
}
ViewBag.Consultores = db.Users.Where(u => u.Vendedor == true).ToList();
ViewBag.DataFinalDefault = dFim;
ViewBag.DataInicialDefault = dInicio;
ViewBag.DataDiaSemana = DateTime.Today.DayOfWeek;
ViewBag.DataInicioSemana = "";
Dictionary<int, int> ParceirosDict = new Dictionary<int, int>();
foreach (var p in ViewBag.Parceiros)
{
ParceirosDict.Add(p.UserId, p.Leads.Count);
}
var ParceirosDictSorted = ParceirosDict.OrderByDescending(key => key.Value).ToList();
if (ParceirosDictSorted.Count >= 1)
{
var ParceiroOuroId = ParceirosDictSorted[0].Key;
ViewBag.ParceiroOuroNome = db.Users.Find(ParceiroOuroId).FirstName;
ViewBag.ParceiroOuroTotal = ParceirosDictSorted[0].Value;
}
if (ParceirosDictSorted.Count >= 2)
{
var ParceiroPrataId = ParceirosDictSorted[1].Key;
ViewBag.ParceiroPrataNome = db.Users.Find(ParceiroPrataId).FirstName;
ViewBag.ParceiroPrataTotal = ParceirosDictSorted[1].Value;
}
if (ParceirosDictSorted.Count >= 3)
{
var ParceiroBronzeId = ParceirosDictSorted[2].Key;
ViewBag.ParceiroBronzeNome = db.Users.Find(ParceiroBronzeId).FirstName;
ViewBag.ParceiroBronzeTotal = ParceirosDictSorted[2].Value;
}
return View("Index");
}
}
}
Good Morning, I created some pages of errors and some modal by css, but this one giving error when trying to visualize the modal,
instead of loading it the modal it loads a 404 error
ecocash
Good Morning, I created some pages of errors and some modal by css, but this one giving error when trying to visualize the modal,
instead of loading it the modal it loads a 404 error
According to your description, I couldn't understand your issue clearly.
What you mean about loading it the modal it loads a 404 error? Could you please tell me which controller's method(which line) cause this issue?
Since you set the Application_Error, all the exception will go to the Application_Error method.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Hi Brandon, the error occurs in this web page that works with viewbag and modal popup,when I activate the Application_Error, the modal popup gets error page 404
Hi Brandon, the error occurs in this web page that works with viewbag and modal popup,when I activate the Application_Error, the modal popup gets error page 404
Hi Brandon, the error occurs in this web page that works with viewbag and modal popup,when I activate the Application_Error, the modal popup gets error page 404
The reason why you get the 404 error when clicking the model popup is the javascript codes in your view could find the controller view details in your page.
$(function () {
$("#LeadsEmProcesso").click(function () {
var id = $(this).attr("data-id");
$("#LeadsEmProcessoModal").load("Details?id=" + id, function () {
$("#LeadsEmProcessoModal").modal();
})
});
})
I found you firstly load the details view by using load function in your jquery codes.
If the details view couldn't be found it will return 404 error.
If you don't set the Application_Error with redirect, it will not redirect to the error controller. it will just return the 404 error, so you could still see the model popup.
If you set the Application_Error with redirect, it will redirect to the error controller view without showing the model popup.
I suggest you could firstly make sure url "Details?id=...." is right, we could access that page.
Besides,I suggest you could check the codes you have used when click the table. I found you just load the controller's details view instead of show the model popup.
I found you have alread generate the details table in each model popup window. I couldn't understand why you still need load the details view.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I'm glad you have solved the issue, if you feel my answer is right, please mark it as answer, it will help other people who faces the same issue to find the answer more easily.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
19 Points
89 Posts
I can not see modal because of error 404
Feb 11, 2019 12:53 PM|ecocash|LINK
Good Morning, I created some pages of errors and some modal by css, but this one giving error when trying to visualize the modal, instead of loading it the modal it loads a 404 error
global:
Star
9831 Points
3120 Posts
Re: I can not see modal because of error 404
Feb 12, 2019 07:10 AM|Brando ZWZ|LINK
Hi ecocash,
According to your description, I couldn't understand your issue clearly.
What you mean about loading it the modal it loads a 404 error? Could you please tell me which controller's method(which line) cause this issue?
Since you set the Application_Error, all the exception will go to the Application_Error method.
Best Regards,
Brando
Member
19 Points
89 Posts
Re: I can not see modal because of error 404
Feb 12, 2019 10:31 AM|ecocash|LINK
Hi Brandon, the error occurs in this web page that works with viewbag and modal popup,when I activate the Application_Error, the modal popup gets error page 404
https://drive.google.com/open?id=1OsdVzCJRTirBKuB1gvlEU9D800KC2QgA
https://drive.google.com/open?id=1K9k4rZIr4CEFc6qYYsrvK3_IZA_59Rqe
Member
19 Points
89 Posts
Re: I can not see modal because of error 404
Feb 12, 2019 04:19 PM|ecocash|LINK
Hi Brandon, the error occurs in this web page that works with viewbag and modal popup,when I activate the Application_Error, the modal popup gets error page 404
https://drive.google.com/open?id=1OsdVzCJRTirBKuB1gvlEU9D800KC2QgA
https://drive.google.com/open?id=1K9k4rZIr4CEFc6qYYsrvK3_IZA_59Rqe
Star
9831 Points
3120 Posts
Re: I can not see modal because of error 404
Feb 13, 2019 05:29 AM|Brando ZWZ|LINK
Hi ecocash,
The reason why you get the 404 error when clicking the model popup is the javascript codes in your view could find the controller view details in your page.
I found you firstly load the details view by using load function in your jquery codes.
If the details view couldn't be found it will return 404 error.
If you don't set the Application_Error with redirect, it will not redirect to the error controller. it will just return the 404 error, so you could still see the model popup.
If you set the Application_Error with redirect, it will redirect to the error controller view without showing the model popup.
I suggest you could firstly make sure url "Details?id=...." is right, we could access that page.
Besides,I suggest you could check the codes you have used when click the table. I found you just load the controller's details view instead of show the model popup.
I found you have alread generate the details table in each model popup window. I couldn't understand why you still need load the details view.
Best Regards,
Brando
Member
19 Points
89 Posts
Re: I can not see modal because of error 404
Feb 13, 2019 01:19 PM|ecocash|LINK
Thank Brando. as it was not me that generated the view I had not noticed that the java loaded a controller.
I fixed it and it's working now
Star
9831 Points
3120 Posts
Re: I can not see modal because of error 404
Feb 14, 2019 12:14 AM|Brando ZWZ|LINK
Hi ecocash,
I'm glad you have solved the issue, if you feel my answer is right, please mark it as answer, it will help other people who faces the same issue to find the answer more easily.
Best Regards,
Brando