Display a view from another controller in ASP.NET MVC

Yes. By default, ASP.NET MVC checks first in \Views\[Controller_Dir]\, but after that, if it doesn’t find the view, it checks in \Views\Shared. The shared directory is there specifically to share Views across multiple controllers. Just add your View to the Shared subdirectory and you’re good to go. If you do return View(“~/Views/Wherever/SomeDir/MyView.aspx”) You can return … Read more

Preventing SQL Injection in ASP.Net

Try using a parameterized query here is a link http://www.aspnet101.com/2007/03/parameterized-queries-in-asp-net/ Also, do not use OpenQuery… use the this to run the select SELECT * FROM db…table WHERE ref = @ref AND bookno = @bookno More articles describing some of your options: http://support.microsoft.com/kb/314520 What is the T-SQL syntax to connect to another SQL Server? Edited Note: … Read more

Why does the 2nd T-SQL query run much faster than the first when called by Reporting Services 2005 in a web-app

You may have come across a query that has an issue with parameter sniffing, which has to do with how Sql Server tries to optimise your query execution plan but in cases when Reporting Services is involved completely messes it up and makes it run incredibly slowly. I had a case with a report that … Read more

How to delete a row from GridView?

You are deleting the row from the gridview but you are then going and calling databind again which is just refreshing the gridview to the same state that the original datasource is in. Either remove it from the datasource and then databind, or databind and remove it from the gridview without redatabinding.

ASP.NET MVC – Session is null

Solution 1: Link: HttpContext.Current.Session is null when routing requests Got it. Quite stupid, actually. It worked after I removed & added the SessionStateModule like so: <configuration> … <system.webServer> … <modules> <remove name=”Session” /> <add name=”Session” type=”System.Web.SessionState.SessionStateModule”/> … </modules> </system.webServer> </configuration> Simply adding it won’t work since “Session” should have already been defined in the machine.config. … Read more