I'm using ASP.NET Preview 5 (will upgrade soon to Beta) with LINQ2SQL on my recently launched tiny webapp.
I was so proud of my work until Silverlight.net featured it on the first page and it started receiving a more than humble number of visitors.
For some reason, users are sometimes getting "Specified cast invalid" thrown by the LINQ2SQL - this is because unauthenticated users are handled as a "Guest" user, and the Controller is loading information about the user "Guest" for each hit.
In the first page, there is a "Welcome [USERNAME]" on the top which can be easily cached using Donut Caching.
However, down in the middle, there is a "What is Dudlers.com" block which should only be shown to unauthenticated users, and another "About You" block which should only be shown to authenticated users. These blocks are too complicated to be cached using Donut Caching; they are way too different, it will be very messy.
I would like to cache the first by depending on the authentication status of the user. So unauthenticated users (needless to say, the majority) get the "Guest" cached page, and other authenticated users are shown a fresh non-cached page.
Is there an option to specify caching varied by authentication? something like: [OutputCache(VaryBy = Authentication)]
Or is there another non-ASP.NET MVC solution? (perhaps tuning MS SQL)
I hope my question is clear. I'm running Windows 2003 and MS SQL 2005 Express on the same dedicated server.
Thank you!
Introduction to ASP.NET MVC Authentication ASP.NET MVC Authentication is a feature in MVC that helps in making the website highly secure and safe. Authentication is the process of confirming or validating the user’s identity if the user who is trying to access the web page or web application is a genuine user or not.
ASP.NET Core works with SQL Server, Redis, and NCache distributed caches. For more information, see Distributed caching in ASP.NET Core. Cache the content from an MVC view or Razor Page with the Cache Tag Helper. The Cache Tag Helper uses in-memory caching to store data.
Output caching provides you with a very easy method of dramatically improving the performance of your ASP.NET MVC applications. In this tutorial, you learned how to use the [OutputCache] attribute to cache the output of controller actions.
The ASP.NET MVC is a framework that combines the web development features of the ASP.NET with the Model View Controller architecture built upon the ASP.NET framework. In the model view controller design pattern, the concerns are separated from each other for example separating the data extraction login from the display logic.
You don't have to use the donut caching mechanism. ASP.NET has the VaryByCustom
option, that allows you to determine how to vary the caching.
Check this out for more info: http://aspadvice.com/blogs/ssmith/archive/2007/10/29/VaryByCustom-Caching-By-User.aspx
Should work fine for ASP.NET MVC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With