我的asp.net應用程序具有表單身份驗證。當用戶登錄時,他被重定向到一個新的頁面abc.aspx。在這個頁面上,在document.ready上的javascript中,服務調用是針對某些AspNetCompatibilityMode服務的。在服務的攔截器中,我嘗試查找HttpContext.Current,但是當它嚮應用程序發出第一個請求時,攔截器不會獲取HttpContext.Current,並且發現它爲null。在那之後,它永遠不會空,但只能在第一個應用程序的請求上。檢查攔截器時HttpContext.Current爲空
0
A
回答
2
如果你使用WCF,在wcf中沒有HttpContext.Current。您必須在會話中使用Service類的InstanceContextMode。
+0
如果AspNetCompatibilityMode打開,那麼你可以得到HttpContext。我在隨後的調用中獲得它,但問題僅在第一次調用。我認爲這與生成cookie的表單認證有些相關。 – Ankit
1
正確地說,由Peer,WCF中沒有HttpContext。您可以使用OperationContext.Current.RequestContext
你必須遵循以下鏈接
http://www.danrigsby.com/blog/index.php/2008/05/23/understanding-instancecontext-in-wcf/
+0
在攔截器中,您獲取請求上下文而不是操作上下文。 – Ankit
相關問題
- 1. 如何爲ILogger攔截攔截器
- 2. 彈簧:檢查目前的攔截器
- 3. struts2檢查權限攔截器
- 4. 攔截器檢查的CSS和js
- 5. 攔截器不攔截
- 6. java攔截器不攔截
- 7. CacheItemRemovedCallback引發時HttpContext.Current爲空
- 8. HttpContext.Current爲空
- 9. SIGNALR HttpContext.Current爲空
- 10. EJB 3.1攔截器是「攔截器」嗎?
- 11. EJB攔截器vs CDI攔截器
- 12. HttpContext.Current.Session在將其注入攔截器/或在內部攔截器中使用時爲空(mvc4 webapi)
- 13. android上的攔截攔截器
- 14. 城堡攔截器不攔截
- 15. StructureMap攔截器
- 16. EJB3攔截器
- 17. Ninject攔截器
- 18. 在攔截器
- 19. Vue.js攔截器
- 20. Hibernate攔截器
- 21. 從Java攔截之前檢查隊列
- 22. 角攔截檢查響應數據
- 23. 使用異步時HttpContext.Current爲空
- 24. 在C#中使用FileSystemWatcher時HttpContext.Current爲空
- 25. 僅當調試時HttpContext.Current爲空
- 26. Spring Cache攔截器
- 27. Spring RestEasy攔截器
- 28. Unity攔截器 - TransparentProxyInterceptor
- 29. NHibernate攔截器 - OnFlushDirty
- 30. CDI攔截器在
你可以把一些代碼,以便我們能夠幫助? – Chris