I found a problem in Web Service when I use Asp.Net Ajax rc1.
runhttp://localhost/Website1/WebService1.asmx, Call SetValue() , then GetValue(). You will find an exception.
That's too strange. why is NHibernate?
using System.Web.Script.Services;
using NHibernate;
using NHibernate.Cfg;
[ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
public void SetValue(string value)
{
// If I run it here, the Session["SESSION1"] in GetValue() will return null;
NHibernate.Cfg.Configuration _cfg = new NHibernate.Cfg.Configuration();
Session["SESSION1"] = value;
}
[WebMethod(EnableSession = true)]
public string GetValue()
{
return Session["SESSION1"].ToString();
}
}
web.config:
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpHandlers>
Yes, if I remove that NHibernate line, all the things are working well. I tried it many times.
I can't use NHibernate in Asp.Net Ajax? I am almost crazy these days.
I've found why the session will be lost. I have a global.asa file. And I write:
void Application_Start(object sender, EventArgs e)
{
log4net.Config.DOMConfigurator.Configure();
}
and each time I call web method, the application will restart ( seems in compiling again ). That's why the session will be cleaned.
But I still don't know why the Application will restart each time? And if I delete that line in Application_Start, everything works well.
I am using Visual Web Developer 2005, and the solution will not compile to a dll.
hello.
just a guess: does the configure methodf loads the config fromthe web.config file? if so, try changing it to an external file (i'm thinking that maybe it may be changing the web.config file while it reads it and this will definitly restart your web app).
No, I didn't change web.config file while I call these 2 method.
I am using visual web develop 2005 express. and all the code wouldn't be compiled to a dll, so I don't know when the code will be compiled if I call a web service method.
No comments:
Post a Comment