Dropdown
dynamic list and database image return does not work after the application is published in IIS. When I inspected through the browser I had the following error:
HTTP Error 404.0 - Not Found (with following request: link )
For image I had the following through Inspection:
HTTP Error 404.0 - Not Found (with following request: link
View create:
$(function () {
$("#Ilha").change(function () {
$.getJSON("/funcionario/Concelho/List/" + $("#Ilha > option:selected").attr("value"), function (data) {
var items = "<option>--Selecione--</option>";
$.each(data, function (i, concelho) {
items += '<option value="' + concelho.Value + '">' + concelho.Text + '</option>';
});
$("#Concelho").html(items);
});
});
});
In my routeconfig
I created Url:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"SelectConcelho",
url: "Soldado/Concelho/List/{id}",
defaults: new { controller = "Soldado", action = "SelectConcelho", id = "" }
);.....
and controller is the method:
[HttpGet]
[Authorize]
public ActionResult SelectConcelho(String id)
{
SITMSEntities conetContext = new SITMSEntities();
int ids;
List<SelectListItem> ConcelhoNome = new List<SelectListItem>();
if (!string.IsNullOrEmpty(id))
{
ids = Convert.ToInt32(id);
List<Concelho> Concelhos = conetContext.Concelho.Where(s => s.Numero_ilha == ids).ToList();
Concelhos.ForEach(s =>
{
ConcelhoNome.Add(new SelectListItem { Text = s.Nome, Value = s.Numero.ToString() });
}
);
}
return Json(ConcelhoNome, JsonRequestBehavior.AllowGet);
}
[Authorize]
public ActionResult RetrieveImage(int id) {
byte[] cover = GetImageFromDataBase(id);
if (cover != null) {
return File(cover, "image/jpg");
} else {
return null;
}
}
and in view
I have:
<img src="/funcionario/RetrieveImage/ @Html.DisplayFor(model => model.Numero)" alt="" height=80 width=80 />