Hi,
Hi,
You need to first Register Route in global.asax like below
C#
routes.MapRoute("SQL", "{controller}/{action}/{Layer}", new { controller = "Images", action = "SQL", Layer = UrlParameter.Optional });
And your ActionMethod will be like below
public ActionResult SQL()
{
using (var context = new WebApplication5Context())
{
string query = "SELECT * FROM dbo.Images WHERE Layer='" + this.RouteData.Values["Layer"].ToString() + "'";
var images = context.Images.SqlQuery(query).ToList();
return View(images.AsEnumerable());
}
}
And wherever you are accessing SQL Action method use url pattern like
"~/Images/SQL/2"
I hope this will help you out.