473,699 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpHandlerFac tory interaction with VisualStudio

I am building an IHttpHandlerFac tory to process all requests to folders in my
site.

When an attempt to access internal folders is detected the request is
rerouted to an error page.

All other attempts are processed using

return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);

This results in a situation created when I start my solution in VisualStudio.

VisualStudio accesses a temporary page
"<domain>/<application>/vs-xxxxx-tmp.htm.

The result is that VisualStudio will not start the web project and says that
the physical location doesn't map to the URL.

What should the IHttpFactory return when it detects a visual studio start
attempt?

Is there a better way to gracefully leave the factory than via PageParser?

Any help would be appreciated.

--
John H Clark
www.weownit.coop
Nov 19 '05 #1
5 1377
Hi John, another thing i forgot to mention in my last post was to catch
requests for real items... in this case your .proj files
'Ignore real files
If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath)) Then

'catch your .axd request and ignore processing them

Dim isAXD As Boolean = False
isAXD =
c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd") > -1

If Not isAXD Then
' do your processing here
End If


end if

"John H Clark" wrote:
I am building an IHttpHandlerFac tory to process all requests to folders in my
site.

When an attempt to access internal folders is detected the request is
rerouted to an error page.

All other attempts are processed using

return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);

This results in a situation created when I start my solution in VisualStudio.

VisualStudio accesses a temporary page
"<domain>/<application>/vs-xxxxx-tmp.htm.

The result is that VisualStudio will not start the web project and says that
the physical location doesn't map to the URL.

What should the IHttpFactory return when it detects a visual studio start
attempt?

Is there a better way to gracefully leave the factory than via PageParser?

Any help would be appreciated.

--
John H Clark
www.weownit.coop

Nov 19 '05 #2
London,

The "last post" went astray. Would you please repost?

Many Thanks...

--
John H Clark
www.weownit.coop
"london calling" wrote:
Hi John, another thing i forgot to mention in my last post was to catch
requests for real items... in this case your .proj files
'Ignore real files
If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath)) Then

'catch your .axd request and ignore processing them

Dim isAXD As Boolean = False
isAXD =
c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd") > -1

If Not isAXD Then
' do your processing here
End If


end if

"John H Clark" wrote:
I am building an IHttpHandlerFac tory to process all requests to folders in my
site.

When an attempt to access internal folders is detected the request is
rerouted to an error page.

All other attempts are processed using

return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);

This results in a situation created when I start my solution in VisualStudio.

VisualStudio accesses a temporary page
"<domain>/<application>/vs-xxxxx-tmp.htm.

The result is that VisualStudio will not start the web project and says that
the physical location doesn't map to the URL.

What should the IHttpFactory return when it detects a visual studio start
attempt?

Is there a better way to gracefully leave the factory than via PageParser?

Any help would be appreciated.

--
John H Clark
www.weownit.coop

Nov 19 '05 #3
Hi John, Sorry for the confusion, the "last post" was the one in the other
thread.

Here is an example of an IHttpModule which should ignore real files e.g. the
..proj files that VS needs when it connects to the web server. It is stripped
out of a project I'm working on at the moment. I've had to take quite a lot
of app specific stuff out and I haven't tested it but... HTH jd

Public Class ExampleModule
Implements Web.IHttpModule
Public Sub Dispose() Implements System.Web.IHtt pModule.Dispose

End Sub

Public Sub Init(ByVal app As System.Web.Http Application) Implements
System.Web.IHtt pModule.Init
AddHandler app.BeginReques t, AddressOf Application_Beg inRequest
AddHandler app.EndRequest, AddressOf Application_End Request
End Sub

Private Sub Application_Beg inRequest(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath))
Then

Dim isAXD As Boolean = False
isAXD = c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd")
-1
If Not isAXD Then

c.Items.Add("St artTime", Now.Ticks)
'************** *************** *************** ******
'
' change this bit to use your own IHttpHandlerFac tory
' or Web.UI.PagePars er.GetCompiledP ageInstance
'
'************** *************** *************** ******

Dim pathTranslated As String

Dim myFactory As Web.IHttpHandle rFactory
c.Handler = myFactory.GetHa ndler(c, c.Request.Reque stType,
c.Request.Url.T oString, pathTranslated)
c.Handler.Proce ssRequest(c)
c.Response.End( )
End If
End If


End Sub

Private Sub Application_End Request(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

Dim t2 As Int64 = Now.Ticks
Dim ts As Int64 = t2 - c.Items.Item("S tartTime")

Dim secs As Double = (1 / TimeSpan.FromSe conds(1).Ticks) * ts

'
' do not include the next line if you are streaming binaries!!!
'

'c.Response.Wri te("<!-- Page Processed in " + secs.ToString + "
seconds. -->")
End Sub

End Class

"John H Clark" wrote:
London,

The "last post" went astray. Would you please repost?

Many Thanks...

--
John H Clark
www.weownit.coop
"london calling" wrote:
Hi John, another thing i forgot to mention in my last post was to catch
requests for real items... in this case your .proj files
'Ignore real files
If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath)) Then

'catch your .axd request and ignore processing them

Dim isAXD As Boolean = False
isAXD =
c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd") > -1

If Not isAXD Then
' do your processing here
End If


end if

"John H Clark" wrote:
I am building an IHttpHandlerFac tory to process all requests to folders in my
site.

When an attempt to access internal folders is detected the request is
rerouted to an error page.

All other attempts are processed using

return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);

This results in a situation created when I start my solution in VisualStudio.

VisualStudio accesses a temporary page
"<domain>/<application>/vs-xxxxx-tmp.htm.

The result is that VisualStudio will not start the web project and says that
the physical location doesn't map to the URL.

What should the IHttpFactory return when it detects a visual studio start
attempt?

Is there a better way to gracefully leave the factory than via PageParser?

Any help would be appreciated.

--
John H Clark
www.weownit.coop

Nov 19 '05 #4
I've just realised the "other thread" wasn't your thread, it was "Subject:
Virtual / Dynamic Folder" jd

"london calling" wrote:
Hi John, Sorry for the confusion, the "last post" was the one in the other
thread.

Here is an example of an IHttpModule which should ignore real files e.g. the
.proj files that VS needs when it connects to the web server. It is stripped
out of a project I'm working on at the moment. I've had to take quite a lot
of app specific stuff out and I haven't tested it but... HTH jd

Public Class ExampleModule
Implements Web.IHttpModule
Public Sub Dispose() Implements System.Web.IHtt pModule.Dispose

End Sub

Public Sub Init(ByVal app As System.Web.Http Application) Implements
System.Web.IHtt pModule.Init
AddHandler app.BeginReques t, AddressOf Application_Beg inRequest
AddHandler app.EndRequest, AddressOf Application_End Request
End Sub

Private Sub Application_Beg inRequest(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath))
Then

Dim isAXD As Boolean = False
isAXD = c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd")
-1


If Not isAXD Then

c.Items.Add("St artTime", Now.Ticks)
'************** *************** *************** ******
'
' change this bit to use your own IHttpHandlerFac tory
' or Web.UI.PagePars er.GetCompiledP ageInstance
'
'************** *************** *************** ******

Dim pathTranslated As String

Dim myFactory As Web.IHttpHandle rFactory
c.Handler = myFactory.GetHa ndler(c, c.Request.Reque stType,
c.Request.Url.T oString, pathTranslated)
c.Handler.Proce ssRequest(c)
c.Response.End( )
End If
End If


End Sub

Private Sub Application_End Request(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

Dim t2 As Int64 = Now.Ticks
Dim ts As Int64 = t2 - c.Items.Item("S tartTime")

Dim secs As Double = (1 / TimeSpan.FromSe conds(1).Ticks) * ts

'
' do not include the next line if you are streaming binaries!!!
'

'c.Response.Wri te("<!-- Page Processed in " + secs.ToString + "
seconds. -->")
End Sub

End Class

"John H Clark" wrote:
London,

The "last post" went astray. Would you please repost?

Many Thanks...

--
John H Clark
www.weownit.coop
"london calling" wrote:
Hi John, another thing i forgot to mention in my last post was to catch
requests for real items... in this case your .proj files
'Ignore real files
If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath)) Then

'catch your .axd request and ignore processing them

Dim isAXD As Boolean = False
isAXD =
c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd") > -1

If Not isAXD Then
' do your processing here
End If


end if

"John H Clark" wrote:

> I am building an IHttpHandlerFac tory to process all requests to folders in my
> site.
>
> When an attempt to access internal folders is detected the request is
> rerouted to an error page.
>
> All other attempts are processed using
>
> return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);
>
> This results in a situation created when I start my solution in VisualStudio.
>
> VisualStudio accesses a temporary page
> "<domain>/<application>/vs-xxxxx-tmp.htm.
>
> The result is that VisualStudio will not start the web project and says that
> the physical location doesn't map to the URL.
>
> What should the IHttpFactory return when it detects a visual studio start
> attempt?
>
> Is there a better way to gracefully leave the factory than via PageParser?
>
> Any help would be appreciated.
>
> --
> John H Clark
> www.weownit.coop

Nov 19 '05 #5
London,

Many thanks for the tip. Works like a charm.

John
--
John H Clark
www.weownit.coop
"london calling" wrote:
Hi John, Sorry for the confusion, the "last post" was the one in the other
thread.

Here is an example of an IHttpModule which should ignore real files e.g. the
.proj files that VS needs when it connects to the web server. It is stripped
out of a project I'm working on at the moment. I've had to take quite a lot
of app specific stuff out and I haven't tested it but... HTH jd

Public Class ExampleModule
Implements Web.IHttpModule
Public Sub Dispose() Implements System.Web.IHtt pModule.Dispose

End Sub

Public Sub Init(ByVal app As System.Web.Http Application) Implements
System.Web.IHtt pModule.Init
AddHandler app.BeginReques t, AddressOf Application_Beg inRequest
AddHandler app.EndRequest, AddressOf Application_End Request
End Sub

Private Sub Application_Beg inRequest(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath))
Then

Dim isAXD As Boolean = False
isAXD = c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd")
-1


If Not isAXD Then

c.Items.Add("St artTime", Now.Ticks)
'************** *************** *************** ******
'
' change this bit to use your own IHttpHandlerFac tory
' or Web.UI.PagePars er.GetCompiledP ageInstance
'
'************** *************** *************** ******

Dim pathTranslated As String

Dim myFactory As Web.IHttpHandle rFactory
c.Handler = myFactory.GetHa ndler(c, c.Request.Reque stType,
c.Request.Url.T oString, pathTranslated)
c.Handler.Proce ssRequest(c)
c.Response.End( )
End If
End If


End Sub

Private Sub Application_End Request(ByVal o As Object, ByVal e As
EventArgs)
Dim app As Web.HttpApplica tion = CType(o, Web.HttpApplica tion)
Dim c As Web.HttpContext = app.Context

Dim t2 As Int64 = Now.Ticks
Dim ts As Int64 = t2 - c.Items.Item("S tartTime")

Dim secs As Double = (1 / TimeSpan.FromSe conds(1).Ticks) * ts

'
' do not include the next line if you are streaming binaries!!!
'

'c.Response.Wri te("<!-- Page Processed in " + secs.ToString + "
seconds. -->")
End Sub

End Class

"John H Clark" wrote:
London,

The "last post" went astray. Would you please repost?

Many Thanks...

--
John H Clark
www.weownit.coop
"london calling" wrote:
Hi John, another thing i forgot to mention in my last post was to catch
requests for real items... in this case your .proj files
'Ignore real files
If Not IO.File.Exists( c.Server.MapPat h(c.Request.Url .AbsolutePath)) Then

'catch your .axd request and ignore processing them

Dim isAXD As Boolean = False
isAXD =
c.Request.Url.A bsolutePath.ToL ower.IndexOf("t race.axd") > -1

If Not isAXD Then
' do your processing here
End If


end if

"John H Clark" wrote:

> I am building an IHttpHandlerFac tory to process all requests to folders in my
> site.
>
> When an attempt to access internal folders is detected the request is
> rerouted to an error page.
>
> All other attempts are processed using
>
> return PageParser.GetC ompiledPageInst ance(url, pathTranslated, context);
>
> This results in a situation created when I start my solution in VisualStudio.
>
> VisualStudio accesses a temporary page
> "<domain>/<application>/vs-xxxxx-tmp.htm.
>
> The result is that VisualStudio will not start the web project and says that
> the physical location doesn't map to the URL.
>
> What should the IHttpFactory return when it detects a visual studio start
> attempt?
>
> Is there a better way to gracefully leave the factory than via PageParser?
>
> Any help would be appreciated.
>
> --
> John H Clark
> www.weownit.coop

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3271
by: Bartosz Krzywicki | last post by:
I have the problem with Session object witch is null, when I implement IHttpHandlerFactory. Implementing IRequiresSessionState interface doesn't help. My code is like this: class MyController : IHttpHandlerFactory, System.Web.SessionState.IRequiresSessionState { public virtual IHttpHandler GetHandler (HttpContext context, string requestType, string url, string path) { //some stuff here context.Session = "aaa"; // here Session object is...
3
1672
by: Bartosz Krzywicki | last post by:
I have the problem with Session object witch is null, when I implement IHttpHandlerFactory. Implementing IRequiresSessionState interface doesn't help. My code is like this: class MyController : IHttpHandlerFactory, System.Web.SessionState.IRequiresSessionState { public virtual IHttpHandler GetHandler (HttpContext context, string requestType, string url, string path) { //some stuff here context.Session = "aaa"; // here Session object is...
4
2381
by: AndyE | last post by:
ASP.Net experts : Fairly new to ASP.net, and I'm struggling to register a custom handler in the <httpHandlers> section of my application WebConfig file. At runtime I persistently get the 404 not found error. The syntax I'm using is : <httpHandlers> <add verb="GET"
0
1949
by: Netveloper | last post by:
Hi, I'm playing around with url rewriting and I have come across a problem which I can't seem to get past. The general ide is to have a IHttpHandlerFactory class which checks the incoming request url against a set of predefined rules and creates and return the appropriate IHttpHandler implementation. Inside the IHttpHandler implementations, the request is examined and
3
1539
by: Hope Paka | last post by:
I want to use my custom url extension instead of .aspx. I can achieve this by writing a custom handler that implements the IHttpHandlerFactory. In the GetHandler method of the IHttpHandlerFactory i want to construct a Page class instance and load my other controls to it and return the page instance. This is what .net framework does. There is a small difference what i am thinking and the .net framework has done. .Net Framework calls the...
0
1071
by: Steve B. | last post by:
Hi, We have build a custom class that implement IHttpHandlerFactory in order to handle all request to a IIS web site. In IIS 6, we just added the aspnet_isapi.dll to the list of generic mapping (properties -Wildcards application maps). We also added a line in the web.config in <handlerssection. This is working as expected, all incoming http request are handled by our factory (in which we choose between a custom handler and standard...
2
1180
by: Steven Voordijk | last post by:
I'm using the IHttpHandlerFactory to do URL rewriting and generate webpages. One of those pages offers the possibility to upload a file with a <input type="file"...tag. When the user clicks the submit button, the file should be uploaded and saved. But because of the use of the IHttpHandlerFactory (I think...) the Current.Request.Files.Count stays 0... (and I can't "get my hands" on the file uploaded). What code should I use to see if...
0
2140
by: Omar Abid | last post by:
Reason of this project: The Microsoft.VisualBasic.Interaction class exposes many useful commands and methods that were available in Visual Basic like AppActivate, Beep, Callbyname... This tutorial shows how to work with some of them. Project details: 1- From VB 6.0 to VB .net 2.0 2- Useful interaction commands 3- Samples of interaction commands
0
1152
by: Jordan S. | last post by:
I'm just wondering if it's possible to have multiple HttpHandlerFactory classes active at once in an ASP.NET 3.5 app. In particular, I want for the "built-in" HttpHandlerFactory that ships with ASP.NET to service .aspx requests. I separately want for another HttpHandlerFactory that I write to service a SUBSET of those requests. I do plan to implement custom URL Rewriting (via custom http module that I
0
8618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.