473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

NullReferenceException in RewritePath()

Hi Guys... I use the RewritePath method to rewrite the internal path within the context.BeginRequest event. It’s working fine in my local System, but throwing System.NullReferenceException in the server.

So what could cause this error?

here is my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web;
  5.  
  6. public class Redirect : IHttpModule
  7. {
  8.     public Redirect() { }
  9.  
  10.  
  11.  
  12.     public void Dispose()
  13.     {
  14.  
  15.     }
  16.  
  17.     public void Init(HttpApplication context)
  18.     {
  19.         context.BeginRequest += new EventHandler(context_BeginRequest);
  20.  
  21.     }
  22.  
  23.  
  24.     void context_BeginRequest(object sender, EventArgs e)
  25.     {
  26.         HttpApplication AppObject = (HttpApplication)sender;
  27.         {
  28.             string serverName = HttpUtility.UrlEncode(AppObject.Request.ServerVariables["SERVER_NAME"]);
  29.             string filePath = AppObject.Request.FilePath;
  30.             string queryurl = AppObject.Request.Url.Query;
  31.             string absURL = AppObject.Request.Url.AbsoluteUri;
  32.  
  33. ///Some condition
  34.  
  35.             string NewURLa = "/Default.aspx?TabId=189&NewsId=32453";
  36.             HttpContext.Current.RewritePath(NewURLa);
  37.         }
  38.     }
  39. }
  40.  
  41.  
here is Exception

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.

at DotNetNuke.Services.Localization.Localization.GetE nabledLocales()

at DotNetNuke.Framework.PageBase.get_PageCulture()

at DotNetNuke.Framework.PageBase.OnInit(EventArgs e)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

--- End of inner exception stack trace ---

at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context)

at System.Web.UI.Page.ProcessRequest(HttpContext context)

at ASP.default_aspx.ProcessRequest(HttpContext context)

at System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()

at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)

Thanks
Jul 22 '11 #1
0 1138

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Matt Howeson | last post by:
Some time ago I posted a request for help with a problem I was having sometime ago whereby a 404 error would result if any access to the Querystring had been made before the Context.Rewritepath is...
5
by: Guadala Harry | last post by:
I'd really appreciate it if someone would give me a"plain English" explanation of HttpContext.RewritePath(). I read the MSDN documentation, but still don't understand it. According to MSDN:...
2
by: Corey O'Mara | last post by:
Hello all, I'd like to have personalized URL's in my application. For example, http://mydomain.com/sites/page.aspx should be accessible via http://mydomain.com/sites/username/page.aspx. I'd like...
8
by: Jiho Han | last post by:
Can someone explain in layman's term, what HttpContext.RewritePath does? SDK doc explanation is kind of scant. Does it only affect the request processing for the duration of the processing(meaning...
1
by: Oytun YILMAZ | last post by:
Hi I thing I have found a critical bug about ASP.NET ReWritePath Function Here are the steps to reproduce: I have a solution with this items: "MasterPageWithoutUserControl.aspx"...
15
by: James Higgs | last post by:
For a long time, our product has had a "vanity URLs" feature where nice URLs are mapped to ASPX files in an IHttpModule implementation, using HttpContext.RewritePath(). This has worked beautifully...
3
by: asanford | last post by:
I want to create an ASP.NET web application that receives a form POST message, inspects the data, and reroutes the request to one of many different servers. I wrote an IHttpModule which...
0
by: cpnet | last post by:
I was playing around with Beta 2 of VS2005, .NET 2.0, and built an IHttpModule do allow me to have nice URL's in my web app. It was working great. I had a URL like: ...
0
by: Massimo Necchi | last post by:
Hi everybody, I'm developing a simple web site for a friend of mine and I need an help for the folloeing situation: I am planning to map friendly page name (like '/faq.aspx') to more complicated...
1
by: Keef | last post by:
Hiya... just wondering if anyone else has come across this problem, and if there is a solution... i'm writing a reasonably simple IHttpModule to rewrite URLs ... in the BeginRequest event i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.