Problem running nopCommerce in my local IIS 5.1 (any sugestions?)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
When I go to

http://localhost/default.aspx

The following error appear:



Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 274:            else
Line 275:            {
Line 276:                URL = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path);
Line 277:            }
Line 278:            return URL;


Source File: C:\projects\e-comm.NET solutions\nopcommerce.com\nopCommerce_1.40\Libraries\Nop.Common\Utils\CommonHelper.cs    Line: 276

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) +763
   System.Web.Hosting.ISAPIWorkerRequest.GetServerName() +18
   System.Web.HttpRequest.get_Url() +86
   NopSolutions.NopCommerce.Common.Utils.CommonHelper.GetThisPageURL(Boolean includeQueryString) in C:\projects\e-comm.NET solutions\nopcommerce.com\nopCommerce_1.40\Libraries\Nop.Common\Utils\CommonHelper.cs:276
   NopSolutions.NopCommerce.Common.Utils.CommonHelper.IsAdmin() in C:\projects\e-comm.NET solutions\nopcommerce.com\nopCommerce_1.40\Libraries\Nop.Common\Utils\CommonHelper.cs:176
   NopSolutions.NopCommerce.HttpModules.MembershipHttpModule.Application_BeginRequest(Object sender, EventArgs e) in C:\projects\e-comm.NET solutions\nopcommerce.com\nopCommerce_1.40\Libraries\Nop.HttpModules.MembershipModule\MembershipHttpModule.cs:125
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75



Regards

Ernesto
14 лет назад
This is a pretty common error.

I don't know all the code involved here, but sometimes you are required to do something like this:

HttpContext.Current context = new HttpContext.Current; // create an instance of the object

// then use

URL = context.Request.Url.GetLeftPart(UriPartial.Path);


// Something like that commonly returns an error like that

// Or maybe you have to put:

using System.Web.HttpContext

// at the top of the page

I'm not sure how it is exactly, but it's something like that.
14 лет назад
No, that code does look correct. What it looks like is that instead of returning a string the
HttpContext.Current.Request.Url has not been populated and therefore is null.

dot net doesn't like nulls and when it tries to convert a null to a string it complains.

You have to figure out why the HttpContext.Current.Request.Url object is not being poplulated.

Good Luck

David
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.