I have a server control, that uses Session.
However, when the control is used on the top umbraco page the Context.Session returns always null
If I put control on page with file name (I mean, that I could open it not by
www.mydomain.com, but by
www.mydomain.com/mypage.aspx) the control works fine.
I understand that umbraco http handler can messes with that, but I can't solve this problem.
(Umbraco 4.0.2)
Controls implements IRequiresSessionState.
Steps to reproduce:
1. Create Server Control project (I created it in VS2008 so it would be .NET 3.5), let's call it ControlsForUmbraco
2. Example control code
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.SessionState;
namespace ControlsForUmbraco
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ControlV2 runat=server></{0}:ControlV2>")]
public class ControlV2 : WebControl, IRequiresSessionState
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Context.Session == null)
{
Context.Response.Write("Context.Session==null");
return;
}
else
{
Context.Response.Write("Context.Session!=null");
return;
}
}
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? "[" + this.ID + "]" : s);
}
set
{
ViewState["Text"] = value;
}
}
}
}
3. Compile&upload assembly to umbraco \bin directory
4. Create macro on umbraco, lets call it Cv2, with Assembly name ControlsForUmbraco and Type ControlsForUmbraco.ControlV2
5. Create document type (lets call it UCDocs) with template
6. Template should look like this
Code:<%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html>
<head>
<title><umbraco:Item field="pageTitle" recursive="false" runat="server"></umbraco:Item></title>
</head>
<body>
<form id="Form1" runat="server">
<div class="highertop">
<umbraco:Macro Alias="Cv2" runat="server" />
</div>
</form>
</body>
</html>
</asp:Content>
7. Create document of type UCDocs, lets call it "test" and put it on the top of umbraco pages.
8. Save&publish
9. When you open website via
http://www.mydomain.com you should see
Quote:Context.Session==null
However when you open website by
http://www.mydomain.com/test.aspx you would see
Quote:Context.Session!=null
From what I understand my provider (dailyrazor) doesn't support wildcard mapping.
So, my question:
Is it a bug of umbraco? If not maybe someone would enlighten me about the reasons of such behaviour..
Regards,
AN