ASP.Net NH Search and User authentication

20 views
Skip to first unread message

Jason Meckley

unread,
Jul 16, 2010, 2:24:51 PM7/16/10
to nhusers
I have a web app that is using NH search. The indexes are stored off
the root of the virtual directory
~/Index/[folder per entity]

Sometimes our end users are prompted for their user name and password.
they hit cancel, close the browser, return to the page and it appears
all the data was saved correctly. the problem appears to be
intermittent and this wasn't a problem during local development or the
testing server.

here is how session/search is resolved for the web application.
Kernel
.Register(
Component
.For<ISessionFactory>()
.LifeStyle.Singleton
.UsingFactoryMethod(k => k
.Resolve<Configuration>()
.BuildSessionFactory()),
Component
.For<ISession>()
.Forward<IFullTextSession>()
.LifeStyle.Transient
.UsingFactoryMethod(k => k
.Resolve<ISessionFactory>()
.GetCurrentSession()));

the session is scoped per request
public class Global : HttpApplication, IContainerAccessor
{
private static IWindsorContainer container;

protected void Application_Start(object sender, EventArgs e)
{
container = new WindsorContainer(new XmlInterpreter())
.AddFacility<LoggingFacility>("logging")
.AddFacility<FactorySupportFacility>()
.AddFacility<MonoRailFacility>()
.AddFacility<MyFacility>();
}

protected void Application_End(object sender, EventArgs e)
{
container.Dispose();
}

protected void Application_Error(object sender, EventArgs e)
{
var exception = Server.GetLastError();
if(exception == null) return;

Container
.Resolve<ILoggerFactory>()
.Create(typeof (Global))
.Error(exception.Message, exception);
}

public Global()
{
BeginRequest += OpenSession;
EndRequest += DisposeOfSession;
}

public IWindsorContainer Container
{
get { return container; }
}

private void OpenSession(object sender, EventArgs e)
{
var session = Container.Resolve<ISessionFactory>().OpenSession();
var fullTextSession = Search.CreateFullTextSession(session);
CurrentSessionContext.Bind(fullTextSession);
}

private void DisposeOfSession(object sender, EventArgs e)
{
var factory = Container.Resolve<ISessionFactory>();
CurrentSessionContext.Unbind(factory).Dispose();
}
}

I have looked at permissions. the user has read/write access to the
Index from IIS. the logging directory has read/write access as well
and the logs are empty, so either the error is not logged, or the
there isn't an error that asp.net is picking up.

the event logs show the error
Unable to find assembly 'Lucene.Net, Version=2.3.2.1, Culture=neutral,
PublicKeyToken=null'.
this is logged by the .Net or IIS framework, not my application. The
file is in the bin folder though. framework versions
Nh 2.1.2.4
lucene 2.3.2.1
NH Search 2.0.0.1001

any pointers on where to go from here? Could it be a IIS application
pool reset issue; altering the index changed too many files and IIS
resets the pool? if so, would moving the index to the App_Data
directory prevent this?
Other than that I'm at a loss at this point.

John Davidson

unread,
Jul 16, 2010, 6:30:39 PM7/16/10
to nhu...@googlegroups.com
This most likely has to do with IIS rather than your application. What OS version are you running?

John Davidson


--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.


Jason Meckley

unread,
Jul 17, 2010, 9:20:15 AM7/17/10
to nhusers
Server 2003 IIS 6.0

I altered some of the components.

1. I'm now storing the indexes and logs in the App_Data directory. if
my understanding is correct app_data is the place to store data files.
2. I simplified the session resolution. I'm now using a resolver
rather than the factory support. this way I don't need to worry about
disposal
3. I altered a DataBindAttribute subclass I created (from MR). this
seems to have a positive effect as well. previously I was resolving
the session and accessing the session factory. Now i'm resolving the
factory and accessing the get current session method.

so far the tests have proven successful.

On Jul 16, 6:30 pm, John Davidson <jwdavid...@gmail.com> wrote:
> This most likely has to do with IIS rather than your application. What OS
> version are you running?
>
> John Davidson
>
> > nhusers+u...@googlegroups.com<nhusers%2Bunsu...@googlegroups.com>
> > .

Jason Meckley

unread,
Aug 23, 2010, 12:48:12 PM8/23/10
to nhusers
So this error has returned. It's happening less frequently, but it's
still happening and I cannot figure out why. here is the full error
that is logged to the event viewer. Apparently this error occurs
outside of my logging, because log4net is not picking it up. The
information is saved to both the database and the indexes.

Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1334
Date: 8/23/2010
Time: 12:36:49 PM
User: N/A
Computer: [the server]
Description:
An unhandled exception occurred and the process was terminated.

Application ID: DefaultDomain

Process ID: 4048

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'Lucene.Net, Version=2.3.2.1,
Culture=neutral, PublicKeyToken=null'.

StackTrace: at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name)
at
System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String
objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA,
Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader
objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo,
SizedArray assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String
name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader,
Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray
assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped
record)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum
binaryHeaderEnum)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage methodCallMessage)
at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream
stm)
at System.AppDomain.Deserialize(Byte[] blob)
at System.AppDomain.UnmarshalObject(Byte[] blob)

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Reply all
Reply to author
Forward
0 new messages