Remove (Hide) image folder name from URL using URL rewriting in ASP.Net

Last Reply one month ago By dharmendr

Posted one month ago

routing imge folder in global file

https://www.somamedicare.com/productimg/best-online-pharmacy-to-buy-soma.jpg

i want remove ( productimg) and new path is 

https://www.somamedicare.com/best-online-pharmacy-to-buy-soma.jpg

how to achieve by using url routing 

my code is on Default page now i do this 

the reason is that this

Serve resources from a consistent URL 

        function getSection2() {
            $.ajax({
                url: "Default.aspx/getproduct1",
                data: '{}',
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                success: function (response) {
                    var rw = "";
                    var data = JSON.parse(response.d);
                    var l = data.length;
                    if (data.length > 0) {
                        rw += ' <tr class="center">';
                        for (var i = 0; i <= data.length - 1; i++) {
                            dis = data[i].disrate;
                            decamt = data[i].salerate - data[i].disrate;
                            productname = data[i].proname + " / "+data[i].mg;
                            rw += '<td>';
                            rw += '<div id=' + data[i].id + ' class="mycard">';
                            rw += '<div class="myimg">';
                            //rw += '<a href="productview.aspx?pname=' + data[i].psid + '">';
                            rw += '<a href="  <%=ResolveUrl("~/category?pname=' + data[i].psid + '") %>">';                        
                            rw += '<img id="proimg" src="' + data[i].img1 + '" alt="' + data[i].alttag + '" />';
                            rw += '</a>';
                            rw += '<div class="showbutton">';
                            rw += '<div class="shownewandoffdiv">';
                            if (dis != '0.00') {
                                var def = data[i].salerate - decamt;
                                var per = (def / data[i].salerate) * 100;
                                rw += '<label class="lblnew2">' + parseFloat(per).toFixed(2) + '% off</label>';
                            }
                            rw += '</div>';
                            rw += '</div>';
                            rw += '</div>';
                            rw += '<p class="productname">' + productname + '</p>';
                            rw += '<div class="ratingproducts"><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star" aria-hidden="true"></i><i class="fa fa-star-half-o" aria-hidden="true"></i><span></span></div>'
                            rw += '<div class="mrpproduct">';
                            if (dis != '0.00') {
                                // rw += '<span>MRP : <span id="prorate">' + data[i].salerate + '.00&#x24;</span>   </span> <span>' + data[i].disrate + '.00&#x24; off  </span> <span>Price : ' + decamt + '.00&#x24;  </span>';
                                 rw += '<span>MRP : <span id="prorate">' + data[i].salerate + '.00&#x24;</span>   </span>  <span>Price : ' + decamt + '.00&#x24;  </span>';
                            }
                            else {
                                rw += '<span  style=" text-decoration: none !important;">Price &#x24; <span id="prorate" style=" text-decoration: none !important;">' + data[i].salerate + '</span>';
                            }
                            rw += '</div>';
                            rw += '<div class="addproducts">';
                            rw += '<input id="itemid" type="text" value=' + data[i].id + ' class="itemid" />';
                            rw += '<input id="Button3" type="button" value="ADD TO CART" class="mybtn22" onclick="addtokartsection2(' + data[i].id + ',\'' + productname + '\');" />';
                            rw += '</div>';
                            rw += '</div>';
                            rw += '</td>';
                        }
                        rw += '</tr>';
                        $('.tblsection22').append(rw);
                    }
                }
            })
        }

 

Posted one month ago

Hi SajidHussa,

Using Global.asax its not possible. 

You need to use URL Rewritting.