I am using asp.net and MVC4 for my application and also i am using bundling for css and js files.
When i look into my trace files, i observed that all my bundle requests are using session. i.e, all bundle requests are passing through sessionstatemodule.
My trace looks like below.
155. NOTIFY_MODULE_START ModuleName="Session", Notification="REQUEST_ACQUIRE_STATE", fIsPostNotification="false" 06:59:43.480
156. AspNetPipelineEnter Data1="System.Web.SessionState.SessionStateModule" 06:59:43.480
157. AspNetSessionDataBegin 06:59:43.480
158. AspNetSessionDataEnd 06:59:43.996
159. AspNetPipelineLeave Data1="System.Web.SessionState.SessionStateModule" 06:59:43.996
160. NOTIFY_MODULE_COMPLETION ModuleName="Session", Notification="REQUEST_ACQUIRE_STATE", fIsPostNotificationEvent="false", CompletionBytes="0", ErrorCode="The operation completed successfully. (0x0)" 06:59:43.996
161. NOTIFY_MODULE_END ModuleName="Session", Notification="REQUEST_ACQUIRE_STATE", fIsPostNotificationEvent="false", NotificationStatus="NOTIFICATION_CONTINUE" 06:59:43.996
I think i dont need session access for my bundle requests. How can i disable the session access for my bundle requests?
If I understand your question correctly you want to disable session state for your static resources. For this you can do two things:
1) Disable
SessionState
forController
For that you need to import
System.Web.SessionState
namespace and you then decorate your controller with following line of code:For more information you can visit following link:
Controlling Session State Behavior
2) Create Static Resources
IIS Setup:
Create two website in your inetpub directory.
Now point them to same physical directory i.e.
Redirect domain.com to www.domain.com
Redirect any domain.com request to www.domain.com.
** Code changes**
Add below code in your web.config file:
use
PreApplicationStartMethod
andMicrosoft.Web.Infrastructure
to dynamically register HTTP module in pre-application startup stage}
Add an Extension Method
Now use
@Url.StaticContent()
from view so that it will render static resource url with static.domain.com whether it is image, script, CSS, or bundles or wherever we want to refer cookieless domain. for e.g.Visit below link for full information as article is pretty big:
Cookie less domain for bundling and static resources
Hope this will help you to achieve your goal.