The main problem here is
url: "~/Controllers/CustomerController/GetImage/",
, ~ , , ASP.net, . ASP.Net. 2 -
URL . JS , , ASP.net , . , ASP.net , . - , 2 -
ASP.net MVC, . MVC - . ASP.net (.aspx,.ascx) . MVC . , ( Global.asax), URL- . MVC -
<host>/{controller}/action
-
'localhost/Home/Index'
, HomeController, Controller.
, , , ( , ) -
$.ajax({
url: "Customer/GetImage",
type: 'POST',
contentType: 'application/json',
data: "url="+url,
success: function (image) {
document.getElementById("image").src = "data:image/png;base64," + image;
showImage();
}
});
, , -
[HttpPost]
public JsonResult GetImage(string url)
{
}
UPDATE:
maproute ( ) . . , , . -
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
"...",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute(
"...",
"{controller}/{action}",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute(
"...",
"{controller}/{action}/{id}",
new { controller = "Customer", action = "GetImage", id = "" }
);
routes.MapRoute(
"...",
"Customer/GetImage/{id}",
new { controller = "Customer", action = "GetImage", id = "" }
);
.....
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}