Methods missed

  • Thread starter Thread starter Erick
  • Start date Start date
E

Erick

Hi,

I'm implementing a IHttpModule.

I get the Context object like this:

HttpContext m_HttpContext = (HttpContext)((HttpApplication)
sender).Context);

this is done on the BeginRequest event of the Custom
module when I try to access the following statemen:

m_HttpContext.Request.Path.EndsWith("Login.aspx");

I did not receive any error at the compile or run time but
if I debug and watch this sentence I see this text into
the value field of the watcher.

error: 'm_HttpContext.Request.Path.EndsWith' does not exist

Looks that the EndsWith method is not recongnized for the
Path string object contained into the Request object.

Does any know what is going on?

Regards...
..
 
Hi Erick,

You might need to specify explicit type casts for the "intermediate"
properties such as Request.

Also try to bring the m_HttpContext.Request.Path into the debugger, its
value will be shown and you will then easily figure out which substring it
actually ends with.
 
Thanks Dmitry for you answer.

Bellow you can see the OnAuthenticateRequest event
captured into the Module which I'm trying to develop. As
you can see I have cast the intermeditaed objects either
the Path property to a string. But again it wont work.

I have debuged the code and I see a value into the Path
property but I cannot use any of the methods that a String
object have.


//+--------------------------------------------+
private void OnAuthenticateRequest(Object sender,
EventArgs e)
{
// Get the Application context
HttpContext m_HttpContext = (HttpContext)((HttpApplication)
sender).Context;
// Get Request object
HttpRequest m_Request = (HttpRequest)m_HttpContext.Request;
string vPath = (string)m_Request.Path;

// Validate if the users identity is already set and the
path is not the same as the LogIn module
if(m_HttpContext.User == null && !vPath.EndsWith
("Login.aspx") )
{
// Retrive values to create the right URL to be redirected
string vStrServerName = HttpUtility.UrlEncode
(m_HttpContext.Request.ServerVariables["SERVER_NAME"]);
string vStrVirtualDir =
m_HttpContext.Request.ApplicationPath;
string vStrServerPort =
m_HttpContext.Request.ServerVariables["SERVER_PORT"];

string vStrToURL = String.Format("http://{0}:{1}{2}/{3}",
vStrServerName, vStrServerPort,
vStrVirtualDir, "Login/Login.aspx");
// Redirecting to the Login page
m_HttpContext.Response.Redirect(vStrToURL);
}

}
-----Original Message-----
Hi Erick,

You might need to specify explicit type casts for the "intermediate"
properties such as Request.

Also try to bring the m_HttpContext.Request.Path into the debugger, its
value will be shown and you will then easily figure out which substring it
actually ends with.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Erick said:
Hi,

I'm implementing a IHttpModule.

I get the Context object like this:

HttpContext m_HttpContext = (HttpContext) ((HttpApplication)
sender).Context);

this is done on the BeginRequest event of the Custom
module when I try to access the following statemen:

m_HttpContext.Request.Path.EndsWith("Login.aspx");

I did not receive any error at the compile or run time but
if I debug and watch this sentence I see this text into
the value field of the watcher.

error: 'm_HttpContext.Request.Path.EndsWith' does not exist

Looks that the EndsWith method is not recongnized for the
Path string object contained into the Request object.

Does any know what is going on?

Regards...
.

.
 
Back
Top