Can I use OutputCache with file dependency in ASP.Net MVC? - asp.net-mvc-3

I have a child action method. Can I use OutputCache with file dependency?I can see only SQLDependency property in System.Web.Mvc.OutputCacheAttribute.

Yes you can use outputcache with file dependency. Check the following link for more detail.
http://msdn.microsoft.com/en-us/library/67z4z916.aspx
OR
http://www.c-sharpcorner.com/UploadFile/chinnasrihari/Asp-Net-mvc-framework-server-side-html-caching-techniques/

Related

Session state controller in Umbraco

I have a custom controller in ~/Controllers/Api/Test.cs inherited from SurfaceController.
What will be routed URL for it ?
All is documented here: https://our.umbraco.org/documentation/reference/routing/surface-controllers. If it supposed to be an API controller, you should probably inherit from UmbracoApiController to be able to use standard WebAPI features with addition of Umbraco Context and Helper injected inside.
More info about it: https://our.umbraco.org/documentation/Reference/Routing/WebApi/

Is it mandatory to return the view name from controller in spring mvc?

I went through the basic Spring mvc code from this link
http://springinpractice.com/2008/05/05/build-a-shopping-cart-with-spring-web-flow-2-part-1/
Here I see that the controller method is blank & the request name & the jsp name is same. So automatically the jsp is rendered even when the controller is not returning the name. I don't understand this. Generally the controller is supposed to return the view name.
Can anyone explain this? Thanks
It simply an option that Spring offers. Instead of having to explicitely tell it that the view name is "home", you have the option of not telling what the view name is. If so, by convention, Spring will look for a view that has a name deduced from the request mapping.
See the documentation for details.

How do you add htmlHelpers into the Spark virew

I want to use the htmlHelpers in my spark view but I keep getting the following errors.
error CS0234: The type or namespace name 'Mvc' does not exist in the
namespace 'System.Web' (are you missing an assembly reference?)
I have added the System.Web.Mvc assembly into the project. I have also added the following code into the module (just for the sake of getting it working - I'll probably need to add this code to the bootstrapper --- not sure how to do that yet!)
var settings = new SparkSettings()
.SetDebug(true)
.SetAutomaticEncoding(true)
.AddAssembly("System.Web")
.AddAssembly("System.Web.Mvc")
.AddNamespace("System.Web.Mvc")
.AddNamespace("System.Web.Mvc.Html");
I also tried adding the namespace to a _global.spark file
Can someone tell me exactly what I must do to use the htmlHelpers in my spark view please.
The default Spark base view for Nancy doesn't include the public HtmlHelper Html { get; set; } property.
You can see the default view here.
The Spark view implemented for MVC integration is here, and you'll see the Html property exposed, which allows your Spark view to access it and invoke helpers.
In theory, you can inherit from NancySparkView, and specify that as your base view in your Spark settings, and add that property along with references to System.Web.Mvc etc in that class and your views should then be able to call into the helpers assuming everything is referenced correctly.
I'm not a Nancy expert, but I'm sure the type of the View is different than that of Asp.Net MVC. So, theoretically, you shouldn't be able to use MVC helpers, since they require the Html property on the View.

asp.net mvc - common code to execute when loading any page from the application

Where would such code go? Is there a commonly executed block inside Asp.net mvc 3 application - something that gets executed every time any page is loaded?
You can do this by two ways:
First, you can inherit a base Controller from System.Web.Mvc.Controller. Then you use this base class inherits for your application. By this way, you can handle all action executions by overriding OnActionExecuting method of your base controller.
Second and better solution is using Custom Action Filters. Create a custom filter and register it globally in Global.asax file like this:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new YourCustomFilter());
}
Global.asax (ex: http://www.dotnetcurry.com/ShowArticle.aspx?ID=126) or inside the _Layout, it depends on what you're doing.
Just so you know the Global.asax file is also available in ASP.NET Webforms.

Set request attribute and then redirect to another app in a Spring Controller

How can I set a request attribute and then redirect that to another app in a Spring Controller.
Thanks!
Please look at this answer, I think this is what are you looking for
How to pass model attributes from one Spring MVC controller to another controller?

Resources