Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET, Class Libraries, and HTTP Handlers

Reply
Thread Tools

ASP.NET, Class Libraries, and HTTP Handlers

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-06-2010
I have a Solution that contains a Web Application and a Class Library. The
Class Library contains an HTTP Handler, which implements IHttpHandler and
needs registered in the config file. I want the *.dll for the Class Library
to be available and work independently of the Web Application. The handler
works when I register the handler in the <httpHandlers> section of the
Web.config file in the Web Application, but how can I register it using the
Class Library? Thanks.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      03-06-2010
Nathan Sokalski wrote:
> I have a Solution that contains a Web Application and a Class Library.
> The Class Library contains an HTTP Handler, which implements
> IHttpHandler and needs registered in the config file. I want the *.dll
> for the Class Library to be available and work independently of the Web
> Application. The handler works when I register the handler in the
> <httpHandlers> section of the Web.config file in the Web Application,
> but how can I register it using the Class Library? Thanks.


A class library uses an app.config.
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-07-2010
I did notice the app.config file in the Class Library, but when I moved the
registration from the Web Application's Web.config to the Class Library's
app.config, it didn't seem to do anything. Is there anything that needs to
be different in any way when the registration is in app.config? Thanks.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Mr. Arnold" <(E-Mail Removed)> wrote in message
news:uS4$(E-Mail Removed)...
> Nathan Sokalski wrote:
>> I have a Solution that contains a Web Application and a Class Library.
>> The Class Library contains an HTTP Handler, which implements IHttpHandler
>> and needs registered in the config file. I want the *.dll for the Class
>> Library to be available and work independently of the Web Application.
>> The handler works when I register the handler in the <httpHandlers>
>> section of the Web.config file in the Web Application, but how can I
>> register it using the Class Library? Thanks.

>
> A class library uses an app.config.


 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      03-07-2010
Nathan Sokalski wrote:
> I did notice the app.config file in the Class Library, but when I moved
> the registration from the Web Application's Web.config to the Class
> Library's app.config, it didn't seem to do anything. Is there anything
> that needs to be different in any way when the registration is in
> app.config? Thanks.


The Web.config is the root of all configs and the app.config is going to
be ignored by the Web application.

You should make a Console project and add the classlib project to the
solution and try the app.config there.
 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      03-07-2010
A DLL in Net is a Class Library not something that is independent working.

If you want the later you can use a service (or a webservice of WFC).

Success

Cor


"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a Solution that contains a Web Application and a Class Library. The
> Class Library contains an HTTP Handler, which implements IHttpHandler and
> needs registered in the config file. I want the *.dll for the Class
> Library to be available and work independently of the Web Application. The
> handler works when I register the handler in the <httpHandlers> section of
> the Web.config file in the Web Application, but how can I register it
> using the Class Library? Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/


 
Reply With Quote
 
Michel Posseth [MCP]
Guest
Posts: n/a
 
      03-07-2010
Actually i created something for that ,, let me switch to my dev computer
( be back in a moment )

Michel



"Mr. Arnold" <(E-Mail Removed)> schreef in bericht
news:%234G$(E-Mail Removed)...
> Nathan Sokalski wrote:
>> I did notice the app.config file in the Class Library, but when I moved
>> the registration from the Web Application's Web.config to the Class
>> Library's app.config, it didn't seem to do anything. Is there anything
>> that needs to be different in any way when the registration is in
>> app.config? Thanks.

>
> The Web.config is the root of all configs and the app.config is going to
> be ignored by the Web application.
>
> You should make a Console project and add the classlib project to the
> solution and try the app.config there.


 
Reply With Quote
 
Michel Posseth
Guest
Posts: n/a
 
      03-07-2010
Op 7-3-2010 10:08, Michel Posseth [MCP] schreef:
> Actually i created something for that ,, let me switch to my dev
> computer ( be back in a moment )
>
> Michel
>
>
>
> "Mr. Arnold" <(E-Mail Removed)> schreef in bericht
> news:%234G$(E-Mail Removed)...
>> Nathan Sokalski wrote:
>>> I did notice the app.config file in the Class Library, but when I
>>> moved the registration from the Web Application's Web.config to the
>>> Class Library's app.config, it didn't seem to do anything. Is there
>>> anything that needs to be different in any way when the registration
>>> is in app.config? Thanks.

>>
>> The Web.config is the root of all configs and the app.config is going
>> to be ignored by the Web application.
>>
>> You should make a Console project and add the classlib project to the
>> solution and try the app.config there.

>




and here it is :

Imports System.Configuration
Imports System.Web.Configuration
Namespace My
Partial Friend NotInheritable Class MySettings
Private DllSettings As ClientSettingsSection
Private DllConfigDoesNotExist As Boolean
Default Public Overrides Property Item(ByVal propertyName As
String) As Object
Get
Dim oValue As Object = Nothing
Try
If RunsOnWeb() Then
' do we have the value in the web config
Dim ret As String = Nothing
Try
ret =
WebConfigurationManager.AppSettings(propertyName)
Catch ex As Exception

End Try
If String.IsNullOrEmpty(ret) Then
Try
oValue =
WebConfigurationManager.ConnectionStrings(property Name).ConnectionString
Catch ex As Exception

End Try
End If
Else
'If the .dll.config file has already been
loaded, use it to obtain the value...
If DllSettings IsNot Nothing Then
oValue =
DllSettings.Settings.Get(propertyName).Value.Value Xml.InnerXml
ElseIf Not DllConfigDoesNotExist Then
If Me.LoadDllConfigFile() Then
oValue =
DllSettings.Settings.Get(propertyName).Value.Value Xml.InnerXml
End If
End If
End If
Catch ex As Exception
End Try
Try
If oValue Is Nothing Then
oValue = MyBase.Item(propertyName)
End If
Catch ex As Exception
End Try
Return oValue
End Get
Set(ByVal value As Object)
MyBase.Item(propertyName) = value
End Set
End Property
Public Function RunsOnWeb() As Boolean
Dim strPN As String =
System.Diagnostics.Process.GetCurrentProcess().Pro cessName.ToLower
Return (strPN = "w3wp" OrElse strPN = "aspnet_wp")
End Function
Private Function LoadDllConfigFile() As Boolean
Dim bDllConfigLoaded As Boolean = False
Dim cfgDll As System.Configuration.Configuration
Dim cfmDllCfg As New ExeConfigurationFileMap()

Dim sAssemblyPath As String =
Reflection.Assembly.GetExecutingAssembly().Locatio n

Dim strNamespace As String = GetType(MySettings).FullName
strNamespace = strNamespace.Substring(0,
strNamespace.IndexOf("."c))


cfmDllCfg.ExeConfigFilename = sAssemblyPath & ".config"
Try

cfgDll =
ConfigurationManager.OpenMappedExeConfiguration(cf mDllCfg,
ConfigurationUserLevel.None)

Dim csgApplicationSettings As ConfigurationSectionGroup
= cfgDll.GetSectionGroup("applicationSettings")
Me.DllSettings =
DirectCast(csgApplicationSettings.Sections(strName space &
".My.MySettings"), ClientSettingsSection)
bDllConfigLoaded = True

Catch ex As Exception

'bestaat niet
DllConfigDoesNotExist = True

End Try
Return bDllConfigLoaded

End Function

End Class

End Namespace




 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      03-07-2010
I probably made a bad choice of words there. What I meant was I want people
to be able to add the *.dll to their web application and use the handler
without needing to register it in their Web.config. The reason I created the
handler is because it is used by one of the controls in my class library (it
generates a *.gif image), so I need the handler to be available to the
control at a known location (unless there is some alternative way for me to
have the *.gif's generated and returned from a URL). Any ideas?
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Cor Ligthert[MVP]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> A DLL in Net is a Class Library not something that is independent working.
>
> If you want the later you can use a service (or a webservice of WFC).
>
> Success
>
> Cor
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I have a Solution that contains a Web Application and a Class Library.
>> The Class Library contains an HTTP Handler, which implements IHttpHandler
>> and needs registered in the config file. I want the *.dll for the Class
>> Library to be available and work independently of the Web Application.
>> The handler works when I register the handler in the <httpHandlers>
>> section of the Web.config file in the Web Application, but how can I
>> register it using the Class Library? Thanks.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/

>

 
Reply With Quote
 
Ralph
Guest
Posts: n/a
 
      03-08-2010
"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I probably made a bad choice of words there. What I meant was I want
> people to be able to add the *.dll to their web application and use the
> handler without needing to register it in their Web.config. The reason I
> created the handler is because it is used by one of the controls in my
> class library (it generates a *.gif image), so I need the handler to be
> available to the control at a known location (unless there is some
> alternative way for me to have the *.gif's generated and returned from a
> URL). Any ideas?
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
> "Cor Ligthert[MVP]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> A DLL in Net is a Class Library not something that is independent
>> working.
>>
>> If you want the later you can use a service (or a webservice of WFC).
>>
>> Success
>>
>> Cor
>>
>>
>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> I have a Solution that contains a Web Application and a Class Library.
>>> The Class Library contains an HTTP Handler, which implements
>>> IHttpHandler and needs registered in the config file. I want the *.dll
>>> for the Class Library to be available and work independently of the Web
>>> Application. The handler works when I register the handler in the
>>> <httpHandlers> section of the Web.config file in the Web Application,
>>> but how can I register it using the Class Library? Thanks.
>>> --
>>> Nathan Sokalski
>>> (E-Mail Removed)
>>> http://www.nathansokalski.com/

>>



Name your file .ashx and it should work without registering.



 
Reply With Quote
 
Ralph
Guest
Posts: n/a
 
      03-08-2010
"Ralph" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I probably made a bad choice of words there. What I meant was I want
>> people to be able to add the *.dll to their web application and use the
>> handler without needing to register it in their Web.config. The reason I
>> created the handler is because it is used by one of the controls in my
>> class library (it generates a *.gif image), so I need the handler to be
>> available to the control at a known location (unless there is some
>> alternative way for me to have the *.gif's generated and returned from a
>> URL). Any ideas?
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>
>> "Cor Ligthert[MVP]" <(E-Mail Removed)> wrote in message
>> news:#(E-Mail Removed)...
>>> A DLL in Net is a Class Library not something that is independent
>>> working.
>>>
>>> If you want the later you can use a service (or a webservice of WFC).
>>>
>>> Success
>>>
>>> Cor
>>>
>>>
>>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> I have a Solution that contains a Web Application and a Class Library.
>>>> The Class Library contains an HTTP Handler, which implements
>>>> IHttpHandler and needs registered in the config file. I want the *.dll
>>>> for the Class Library to be available and work independently of the Web
>>>> Application. The handler works when I register the handler in the
>>>> <httpHandlers> section of the Web.config file in the Web Application,
>>>> but how can I register it using the Class Library? Thanks.
>>>> --
>>>> Nathan Sokalski
>>>> (E-Mail Removed)
>>>> http://www.nathansokalski.com/
>>>

>
>
> Name your file .ashx and it should work without registering.

opps I met without having to add to web.config.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Medium trust and HTTP handlers - help! Linda ASP .Net Security 2 09-05-2006 11:26 PM
http handlers and non existing folders =?Utf-8?B?U2hhdW4=?= ASP .Net 5 07-13-2005 09:07 PM
HTTP handlers and donwload dialog boxes =?Utf-8?B?Sm9yZ2UgUmliZWlybw==?= ASP .Net 0 02-21-2005 06:47 PM
Http handlers and session state Eran Kampf ASP .Net 1 09-23-2004 09:29 PM
HTTP handlers - Maintaining global objects, and multi-threading Chris Hughes ASP .Net 5 08-21-2003 04:12 AM



Advertisments