Marianne Markwardt
Marianne Markwardt

Reputation: 131

C# & ASP.NET MVC - images loading slowly

I am returning around 20ish thumbnails on a page. Problem is that the last few (always around 5~) load very slowly.

No difference whether I am loading them like

using(FileStream ltFS = new FileStream(Server.MapPath("~/Themes/Content/Images/nocover.png"), FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))

or

return File(Server.MapPath("~/Themes/Content/Images/nocover.png"), "image/png");

I google and found this on SO

[SessionState(System.Web.SessionState.SessionStateBehavior.Disabled)]

If I am trying that, I get the error

The SessionStateTempDataProvider class requires session state to be enabled.

enter image description here

Upvotes: 1

Views: 1186

Answers (1)

Krishjs
Krishjs

Reputation: 368

Every request in an ASP.Net web application gets a Session lock at the beginning of a request, and then releases it at the end of the request!.Until that time any other request from the user will wait. If you are using the TempData or Session in MVC methods then there will be asp.net session lock will process the requests one by one.This attribute [SessionState(System.Web.SessionState.SessionStateBehavior.Disabled)] is just to avoid asp.net session lock and the error means that you are using the TempData somewhere in your methods If you are not updating the Session in then try using [SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)] instead

Upvotes: 0

Related Questions