Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 7.5 ActionLink Resource not found in MVC4

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
like image 900
kk1076 Avatar asked Nov 28 '25 03:11

kk1076


1 Answers

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.

like image 50
Stephen Reindl Avatar answered Nov 30 '25 18:11

Stephen Reindl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!