Showing posts with label strange. Show all posts
Showing posts with label strange. Show all posts

Monday, March 26, 2012

Server Transfer To Windows Forms Authenticated Application

Hello,

I am having a really strange issue, I have folder containing an ASP.NET
application. (The folder's name is Web) The root directory of the whole
site I have an Index.aspx page that contains:

<%
Server.Transfer("Web\Default.aspx")
%
The web config file in the Web directory is using an Authentication mode of
Forms. For some reason when the transfer method is called, it thows an:

Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error
can be caused by a virtual directory not being configured as an application
in IIS.

I am running on a shared server, and can't really make it a virtual
directory. Does anyone know a way around this? Could I make it a subweb or
does this need to be a virtual directory?

Thanks.Hi Ryan,

what i understand from your description that u are maintaining a web.config
file in a sub dir also.
Actually Authenticate Mode can only be defined in the application wide
web.config file .

I suggest you remove the Authentication element from the web.config file and
then try running your application. In case you still find errors, try
removing the sessionState and authorization elements as well because they are
also set at application level.

In case you only wish to use Authentication mode as forms, you may have to
create a virtual dir.

HTH

"Ryan" wrote:

> Hello,
> I am having a really strange issue, I have folder containing an ASP.NET
> application. (The folder's name is Web) The root directory of the whole
> site I have an Index.aspx page that contains:
> <%
> Server.Transfer("Web\Default.aspx")
> %>
> The web config file in the Web directory is using an Authentication mode of
> Forms. For some reason when the transfer method is called, it thows an:
> Parser Error Message: It is an error to use a section registered as
> allowDefinition='MachineToApplication' beyond application level. This error
> can be caused by a virtual directory not being configured as an application
> in IIS.
> I am running on a shared server, and can't really make it a virtual
> directory. Does anyone know a way around this? Could I make it a subweb or
> does this need to be a virtual directory?
> Thanks.

Server Transfer To Windows Forms Authenticated Application

Hello,
I am having a really strange issue, I have folder containing an ASP.NET
application. (The folder's name is Web) The root directory of the whole
site I have an Index.aspx page that contains:
<%
Server.Transfer("Web\Default.aspx")
%>
The web config file in the Web directory is using an Authentication mode of
Forms. For some reason when the transfer method is called, it thows an:
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error
can be caused by a virtual directory not being configured as an application
in IIS.
I am running on a shared server, and can't really make it a virtual
directory. Does anyone know a way around this? Could I make it a subweb or
does this need to be a virtual directory?
Thanks.Hi Ryan,
what i understand from your description that u are maintaining a web.config
file in a sub dir also.
Actually Authenticate Mode can only be defined in the application wide
web.config file .
I suggest you remove the Authentication element from the web.config file and
then try running your application. In case you still find errors, try
removing the sessionState and authorization elements as well because they ar
e
also set at application level.
In case you only wish to use Authentication mode as forms, you may have to
create a virtual dir.
HTH
"Ryan" wrote:

> Hello,
> I am having a really strange issue, I have folder containing an ASP.NET
> application. (The folder's name is Web) The root directory of the whole
> site I have an Index.aspx page that contains:
> <%
> Server.Transfer("Web\Default.aspx")
> %>
> The web config file in the Web directory is using an Authentication mode o
f
> Forms. For some reason when the transfer method is called, it thows an:
> Parser Error Message: It is an error to use a section registered as
> allowDefinition='MachineToApplication' beyond application level. This erro
r
> can be caused by a virtual directory not being configured as an applicatio
n
> in IIS.
> I am running on a shared server, and can't really make it a virtual
> directory. Does anyone know a way around this? Could I make it a subweb
or
> does this need to be a virtual directory?
> Thanks.
>

Saturday, March 24, 2012

Server, Session, Request and Response in Classes?

Hi there,

Perhaps a really strange question...

Is there a way that I can access the Server, Session Request and Response objects from the current page request from inside a class (not a web control) without explicitly passing them in from a web control?

My problem is that I have been developing my web application thinking that all static class members would be reset after each page request - but I've just realized that those members keep their values from request to request (and I assume across all users too?) This means I have some major restructuring to do, and the only way I can think of fixing this is to store my user-specific objects in the user session...and thus, I need access to the Session in some of my classes that accessed those static members. :S

Having a tough time wrapping my mind around the whole thing at the moment...I'm used to ASP 5.0. Maybe there's a better way to go about this altogether.

to access those items from a non-page class, you can use:

HttpContext.Current

this will give you access to

HttpContext.Current.Session
HttpContext.Current.Request
etc...


The class member properties/values wont be passed unless you are rebinding them, saving them in session/application or some other way passing them. It's more then likely a matter of how you are populating them that's causing you frustration.

Show the specific code you are using and what you think is the cause of the problem... we'll see what we can do to help out.


I think I know what you mean. Offloading stuff blindly into the user session is not a good idea. I have a lot of restructuring to do...

Speaking of which, there doesn't happen to be a convenient way to get the current instance of the System.Web.UI.Page object from within any class, is there? I couldn't find anything relevant to this in the HttpContext, and I don't know where else to look.

Thanks!!


you shoudnt need it in your class (the business layer should be UI independent).... if, for some reason you do though you'll have to pass in the instance of it.

Draggor:

there doesn't happen to be a convenient way to get the current instance of the System.Web.UI.Page object from within any class, is there?

You can get at the current page instance from HttpContext like this:

Dim currentPageAs Page =DirectCast(HttpContext.Current.Handler, Page)