By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,466 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,466 IT Pros & Developers. It's quick & easy.

show source

P: n/a
Seb
With php I can simply append a s to the file extension, eg. .phps and
if the user request the file the source will be shown in the browser.

Is there a semilar functionality for aspx pages?

best regards,
seb
Jul 28 '08 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Seb has brought this to us :
With php I can simply append a s to the file extension, eg. .phps and
if the user request the file the source will be shown in the browser.

Is there a semilar functionality for aspx pages?

best regards,
seb
What source do you mean? There is the aspx file itself, it's codebehind
file and there may be any number of supporting classes.

Depending on the compilation model used, all of these could be absent
from your server!

As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!

Hans Kesting
Jul 28 '08 #2

P: n/a
Seb
On Jul 28, 3:21*pm, Hans Kesting <news.han...@spamgourmet.comwrote:
Seb has brought this to us :
With php I can simply append a s to the file extension, eg. .phps and
if the user request the file the source will be shown in the browser.
Is there a semilar functionality for aspx pages?
best regards,
seb

What source do you mean? There is the aspx file itself, it's codebehind
file and there may be any number of supporting classes.
aspx, cs and so on.
Depending on the compilation model used, all of these could be absent
from your server!
True, but they aren't :)
As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!
It's so I could easily show my source to a group like this.
best regards,
seb
Jul 31 '08 #3

P: n/a
I do not get your problem...

If you have developed an application then you should have a source.
If you have not then it would be a security problem to allow you to see the
cource.

PS: I tried to add .phps instead of .php on the
http://www.php.net/archive/2008.php
and all i do not see any souce, only custom 404 page
George.

"Seb" <se******************@gmail.comwrote in message
news:bd**********************************@l42g2000 hsc.googlegroups.com...
On Jul 28, 3:21 pm, Hans Kesting <news.han...@spamgourmet.comwrote:
Seb has brought this to us :
With php I can simply append a s to the file extension, eg. .phps and
if the user request the file the source will be shown in the browser.
Is there a semilar functionality for aspx pages?
best regards,
seb

What source do you mean? There is the aspx file itself, it's codebehind
file and there may be any number of supporting classes.
aspx, cs and so on.
Depending on the compilation model used, all of these could be absent
from your server!
True, but they aren't :)
As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!
It's so I could easily show my source to a group like this.
best regards,
seb

Jul 31 '08 #4

P: n/a
Hello George,

Granted, you should have the source code already, but for easier access via
web, the only way I can think to do this would be to create an HTTP Handler,
set it up on the web.config file, and register the file extensions in the
app config on the IIS server. The HTTP handler would intercept, for example,
yourpage.aspx.source calls to the web server and depending on the name prior
to '.source' the handler would grab that file and read the contents out to
you on the webpage, checking code-behind and inline page code. That seems
the best method to me...

If you don't know how to write an HTTP Handler and set it up, there's basically
no way other than to have the original source... Or you could just remove
the aspx mapping in the app config, but then the site wouldn't work at all.
I do not get your problem...

If you have developed an application then you should have a source.
If you have not then it would be a security problem to allow you to
see the
cource.
PS: I tried to add .phps instead of .php on the
http://www.php.net/archive/2008.php
and all i do not see any souce, only custom 404 page
George.

"Seb" <se******************@gmail.comwrote in message
news:bd**********************************@l42g2000 hsc.googlegroups.com
... On Jul 28, 3:21 pm, Hans Kesting <news.han...@spamgourmet.com>
wrote:
>Seb has brought this to us :
>>With php I can simply append a s to the file extension, eg. .phps
and if the user request the file the source will be shown in the
browser.

Is there a semilar functionality for aspx pages?

best regards,
seb
What source do you mean? There is the aspx file itself, it's
codebehind file and there may be any number of supporting classes.
aspx, cs and so on.
>Depending on the compilation model used, all of these could be absent
from your server!
True, but they aren't :)
>As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!
It's so I could easily show my source to a group like this.

best regards,
seb

Jul 31 '08 #5

P: n/a
Sorry, my posting program automatically added George to the top of the response.
The previous one was intended for Seb
I do not get your problem...

If you have developed an application then you should have a source.
If you have not then it would be a security problem to allow you to
see the
cource.
PS: I tried to add .phps instead of .php on the
http://www.php.net/archive/2008.php
and all i do not see any souce, only custom 404 page
George.

"Seb" <se******************@gmail.comwrote in message
news:bd**********************************@l42g2000 hsc.googlegroups.com
... On Jul 28, 3:21 pm, Hans Kesting <news.han...@spamgourmet.com>
wrote:
>Seb has brought this to us :
>>With php I can simply append a s to the file extension, eg. .phps
and if the user request the file the source will be shown in the
browser.

Is there a semilar functionality for aspx pages?

best regards,
seb
What source do you mean? There is the aspx file itself, it's
codebehind file and there may be any number of supporting classes.
aspx, cs and so on.
>Depending on the compilation model used, all of these could be absent
from your server!
True, but they aren't :)
>As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!
It's so I could easily show my source to a group like this.

best regards,
seb

Jul 31 '08 #6

P: n/a
Yea, I guess you could add a Handler,

I would probably analyze query string or path for something like
mypage.aspx?source=1
or
mypage.aspx/source

The problem with mypage.aspx.source is that you would need to register
extension .source with ASP.NET dll (in IIS Management console)
--------------------------------------

Anyway, i never had need to display the source for myslef.... :)

George.

"The Colorado Kid" <tckwrote in message
news:9d*************************@newsgroups.comcas t.net...
Hello George,

Granted, you should have the source code already, but for easier access
via web, the only way I can think to do this would be to create an HTTP
Handler, set it up on the web.config file, and register the file
extensions in the app config on the IIS server. The HTTP handler would
intercept, for example, yourpage.aspx.source calls to the web server and
depending on the name prior to '.source' the handler would grab that file
and read the contents out to you on the webpage, checking code-behind and
inline page code. That seems the best method to me...

If you don't know how to write an HTTP Handler and set it up, there's
basically no way other than to have the original source... Or you could
just remove the aspx mapping in the app config, but then the site wouldn't
work at all.
>I do not get your problem...

If you have developed an application then you should have a source.
If you have not then it would be a security problem to allow you to
see the
cource.
PS: I tried to add .phps instead of .php on the
http://www.php.net/archive/2008.php
and all i do not see any souce, only custom 404 page
George.

"Seb" <se******************@gmail.comwrote in message
news:bd**********************************@l42g200 0hsc.googlegroups.com
... On Jul 28, 3:21 pm, Hans Kesting <news.han...@spamgourmet.com>
wrote:
>>Seb has brought this to us :

With php I can simply append a s to the file extension, eg. .phps
and if the user request the file the source will be shown in the
browser.

Is there a semilar functionality for aspx pages?

best regards,
seb
What source do you mean? There is the aspx file itself, it's
codebehind file and there may be any number of supporting classes.
aspx, cs and so on.
>>Depending on the compilation model used, all of these could be absent
from your server!
True, but they aren't :)
>>As far as I know, it is not possible to request any of these sources
(fortunately!). The retrieval of some support files (*.config for
example) is even actively blocked bij ASP.Net!
It's so I could easily show my source to a group like this.

best regards,
seb

Jul 31 '08 #7

P: n/a
Seb
On Jul 31, 7:23*pm, "George" <noem...@comcast.netwrote:
I do not get your problem...

If you have developed an application then you should have a source.
If you have not then it would be a security problem to allow you to see the
cource.
Not if you want to expose the source to a group like this.
PS: I tried to add .phps instead of .php on thehttp://www.php.net/archive/2008.php
and all i do not see any souce, only custom 404 page
If you change the extension to .phps if will present the source code,
not output of the parsed php code.
Aug 1 '08 #8

P: n/a
Seb
On Jul 31, 10:40*pm, The Colorado Kid <tckwrote:
Hello George,

Granted, you should have the source code already, but for easier access via
web, the only way I can think to do this would be to create an HTTP Handler,
set it up on the web.config file, and register the file extensions in the
app config on the IIS server. The HTTP handler would intercept, for example,
yourpage.aspx.source calls to the web server and depending on the name prior
to '.source' the handler would grab that file and read the contents out to
you on the webpage, checking code-behind and inline page code. That seems
the best method to me...

If you don't know how to write an HTTP Handler and set it up, there's basically
no way other than to have the original source... Or you could just remove
the aspx mapping in the app config, but then the site wouldn't work at all.
Inspired by http://msdn.microsoft.com/en-us/library/ms228090.aspx

Quick and dirty:
using System.Web;
using System.IO;
public class SourceHandler : IHttpHandler
{
public SourceHandler()
{
}

public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
HttpServerUtility Server = context.Server;

string file = File.ReadAllText(Server.MapPath(Request.FilePath)) ;
file = Server.HtmlEncode(file);

file = file.Replace("\r\n", "<br />");
file = file.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");

//surround this with valid html
Response.Write(file);
}

public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}

Thanks a lot :)
Aug 1 '08 #9

P: n/a
Seb
On Jul 31, 11:09*pm, "George" <noem...@comcast.netwrote:
Yea, I guess you could add a Handler,

I would probably analyze query string or path for something like
mypage.aspx?source=1
or
mypage.aspx/source

The problem with mypage.aspx.source is that you would need to register
extension .source with ASP.NET dll (in IIS Management console)
Simply add the handler to web.config
>
Anyway, i never had need to display the source for myslef.... :)
You should share more :)
best regards,
seb
Aug 1 '08 #10

P: n/a
Seb,

Does this method seem to be working for you?
On Jul 31, 10:40 pm, The Colorado Kid <tckwrote:
>Hello George,

Granted, you should have the source code already, but for easier
access via web, the only way I can think to do this would be to
create an HTTP Handler, set it up on the web.config file, and
register the file extensions in the app config on the IIS server. The
HTTP handler would intercept, for example, yourpage.aspx.source calls
to the web server and depending on the name prior to '.source' the
handler would grab that file and read the contents out to you on the
webpage, checking code-behind and inline page code. That seems the
best method to me...

If you don't know how to write an HTTP Handler and set it up, there's
basically
no way other than to have the original source... Or you could just
remove
the aspx mapping in the app config, but then the site wouldn't work
at all.
Inspired by http://msdn.microsoft.com/en-us/library/ms228090.aspx

Quick and dirty:
using System.Web;
using System.IO;
public class SourceHandler : IHttpHandler
{
public SourceHandler()
{
}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
HttpServerUtility Server = context.Server;
string file = File.ReadAllText(Server.MapPath(Request.FilePath)) ;
file = Server.HtmlEncode(file);
file = file.Replace("\r\n", "<br />");
file = file.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
//surround this with valid html
Response.Write(file);
}
public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}
Thanks a lot :)

Aug 1 '08 #11

P: n/a
>>Simply add the handler to web.config
Which version of IIS are you running you code under? Cause it's not that
simple...
If you running it under the Server that comes with Visual Studio (ASP.NET
Development Server) then you are in for some problems once you move it to
production....

George.

"Seb" <se******************@gmail.comwrote in message
news:72**********************************@e53g2000 hsa.googlegroups.com...
On Jul 31, 11:09 pm, "George" <noem...@comcast.netwrote:
Yea, I guess you could add a Handler,

I would probably analyze query string or path for something like
mypage.aspx?source=1
or
mypage.aspx/source

The problem with mypage.aspx.source is that you would need to register
extension .source with ASP.NET dll (in IIS Management console)
Simply add the handler to web.config
>
Anyway, i never had need to display the source for myslef.... :)
You should share more :)
best regards,
seb

Aug 1 '08 #12

P: n/a
Seb
On Aug 1, 7:38*pm, The Colorado Kid <tckwrote:
Seb,

Does this method seem to be working for you?
Locally it does... :(
Aug 3 '08 #13

P: n/a
Seb
On Aug 2, 12:47*am, "George" <noem...@comcast.netwrote:
>Simply add the handler to web.config

Which version of IIS are you running you code under? Cause it's not that
simple...
If you running it under the Server that comes with Visual Studio (ASP.NET
Development Server) then you are in for some problems once you move it to
production....
I realized that... Is there a way to make this work with a standard
host? surftown in my case... or do I need access to iis manager?

best regards,
seb
Aug 3 '08 #14

This discussion thread is closed

Replies have been disabled for this discussion.