In my MVC application, @Html.ActionLink
control works fine in my local machine. The actionlink redirects to the specified action. But when hosted in server, error "Resource not found. Please check the url" occurs.
View Code
@Html.ActionLink(" ", "ExportToQR", "WPCheckout", new { UserID = Request.QueryString["UserID"], Partnerid = Request.QueryString["Partnerid"] }, new { @class = "btnMakeQR" })
Class for button Image
.btnMakeQR
{
background: url(../Images/Generate_QR_Code.png) no-repeat top left;
display: block;
width: 111px;
height: 25px;
text-indent: -9999px;
}
Controller Code
public class WPCheckoutController : Controller
{
public ActionResult ExportToQR()
{
// logic to get encoding value for "qrcode" from database
QRCodeEncoder encoder = new QRCodeEncoder();
Bitmap img = encoder.Encode(qrcode);
string path = Server.MapPath(@"/Images/QRCode.jpg");
img.Save(path, ImageFormat.Jpeg);
return base.File(path,"image/jpeg","OrderDetails.jpg");
}
}
What is the mistake in my code. ?. Any suggestions.
EDIT
This is the url, I get when hovering the button image.
http://localhost/WPCheckout/ExportToQR?UserID=1013&Partnerid=ph111
Looking at your code, it seems that you create a file /Images/QRCode.jpg
. I assume you mean ~/Images/QRCode.jpg
?
In the first case the file will be named http://localhost/Images/QRCode.jpg
which might not be readable by the IIS application due to restriction problems. In the latter case it will become http://localhost/WPcheckout/Images/QRCode.jpg
.
Refering to this comment : /xxx
and ~/xxx
might be different.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.