August 28, 2010

nopCommerce Mail Configuration

To enable mail Settings in nopCommerce deployed on Godaddy Server which will allow customer to fill up the contact form and send information to the Admin through email

  1. Click Configuration.
  2. Click Mail Settings.
  3. Fill up the below information
    Store Admin Email
    Your email address.
    Store Admin Email Display Name
    The name to display on your email.
    (Make sure that the “Store Admin Email” value is something other that a yahoo, hotmail, gmail address – GoDaddy does not allow these domains)
    Host
    relay-hosting.secureserver.net
    Port
    25
    User
    Your full email address.
    Password
    Your email account password.
    Enable SSL
    Do not enable this option.
    Use default credentials
    Do not enable this option.
  4. Click Save.

To enable contact us form, the hack involves getting to the source code.
The problem with Godaddy.com is that it does not allow yahoo, hotmail
or gmail addresses to the “from” email address. Most other email
addresses are allowed

To solve this, go to the file ContactUs.ascx.cs
Within this file, in the method,

btnContactUs_click(), change the line
that starts with
MessageManager.SendEmail(….); to the following:

MessageManager.SendEmail("Contact us form", "Name: " +
txtFullName.Text + "\nEmail: " + txtEmail.Text + "\nEnquiry: " +
txtEnquiry.Text, "admin@yourstore.com", to);

Basically, we have altered the “from” email address to be hard-coded
to something static. We also appended the email address and Name to
the information being sent to the “to” address.

August 27, 2010

SecurityPolicyException : could not load the dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.Design.dll

 After deployment, the Register/Contact links on the
NopCommerce web application gives SecurityPolicyException -- says
could not load the dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.Design.dll

Solution: Do not put this dll in the deployment , If it is there in bin delete that
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.Design.dll

IIS Logon failure: user account restriction

While browsing WebApp from IIS you can come across the below error
Error : iis Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.

Solution :
1.) Go to run type regedit.exe
2.) Go to  HKLM\System\CurrentControlSet\Control\Lsa\limitblankpassworduse
3.) change this value  from 1 to 0

Try to browse again You can come across the below error 
Error : ServerName/ASPNET User Can not access database
Solution 
1.) Go to Directory Security tab of IIS and click on Edit
 2.)Change the user name which is allowed to access the databse and check the IntegratedWindowsAuthentication mode.(If browsing in local Environment)

Failed to access IIS Metabase

The problem comes around due to the order that components were installed on the machine, namely that The .NET Framework was installed before IIS. As a result, ASP.NET is not correctly configured to run. The easiest way to rectify this is to re-install ASP.NET with IIS.
To do this Go to directory

C:\WINDOWS\microsoft.net\framework\v2.0.50727

and run the following command in command prompt

aspnet_regiis –i 

Could not load type 'System.Web.UI.ScriptReferenceBase'

Server Error in '/' Application.

Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

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.TypeLoadException: Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'




Solution :  Install Microsoft 3.5 sp1 from the below link

http://www.microsoft.com/downloads/details.aspx?FamilyID=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en

Generic error occurred in GDI+. Description : Nopcommerce

 generic error occurred in GDI+.
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.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
  System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +377630
  System.Drawing.Image.Save(String filename, ImageFormat format) +69
  NopSolutions.NopCommerce.Common.Media.PictureManager.GetPictureUrl(Picture
picture, Int32 Width, Int32 Height, Boolean showDefaultPicture) in
PictureManager.cs:195
  NopSolutions.NopCommerce.Web.Modules.ProductBox1Control.BindData() +198
  NopSolutions.NopCommerce.Web.Modules.ProductBox1Control.Page_Load(Object
sender, EventArgs e) +33
  System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
Object o, Object t, EventArgs e) +14
  System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
sender, EventArgs e) +35
  System.Web.UI.Control.OnLoad(EventArgs e) +99
  System.Web.UI.Control.LoadRecursive() +50
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Control.LoadRecursive() +141
  System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+627



Solution : Create thumbs directory  inside images and give read/write permission to it

Show LightBox Zoomed Image Even if there is one image added for the product

Nopcommerce1.4 If For the specific product there are more then 1 images added Zoom Image Functionality works using lightbox , but if only one image is there it doesn't work

To Zoom the image using lighbox even if only one image has been added for the product in Nopcommerce.14
Make highlighted changes in following files

1.)In Modules/ProductInfo.ascx
 
<td align="left">
<a href="<%#PictureManager.GetPictureUrl((int)Eval("PictureID"), 600)%>" rel="lightbox-p" title="<%= lProductName.Text%>">

<img src="<%#PictureManager.GetPictureUrl((int)Eval("PictureID"), 70)%>" alt="Product image" /></a>

</td>

2.) In ProductInfo.ascx.cs
ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count >= 1)//Modified For more then 1 image
                {
                    defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureID, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    lvProductPictures.DataSource = productPictures;
                    lvProductPictures.DataBind();
                }

//comment out the below existing code
//else if (productPictures.Count == 1)//commented out for                 //{
                //    defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureID, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                //    defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                //    defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                //    lvProductPictures.Visible = false;
                //}


Hide Product Price if Price Is Zero in Product Description in Nopcommerce


If Product Price is set as zero in Nopcommerce 1.4 You ll see the zero price in Description.
If you want to hide that zero price make the below highlighted changes


1.) In File ProductPrice.ascx  

      Add the outer most panel with id= "pnlHidePrice"

<asp:Panel ID="pnlHidePrice" runat ="server">
<asp:PlaceHolder runat="server" ID="phOldPrice">

    <%=GetLocaleResourceString("Products.OldPrice")%>&nbsp;
    <asp:Label ID="lblOldPrice" runat="server" CssClass="oldProductPrice" />
</asp:PlaceHolder>
<br />
<asp:Label ID="lblPrice" runat="server" Visible="false" />
<asp:Label ID="lblPriceValue" runat="server" CssClass="productPrice" />
<asp:PlaceHolder runat="server" ID="phDiscount">
    <br />
    <%=GetLocaleResourceString("Products.FinalPriceWithDiscount")%>&nbsp;&nbsp;
    <asp:Label ID="lblFinalPriceWithDiscount" runat="server" CssClass="productPrice" />
</asp:PlaceHolder>
</asp:Panel>


2.)In File ProductPrice.ascx.cs 
if (phDiscount.Visible || phOldPrice.Visible)
                {
                   
                    lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
                   
                   
                }

                ////Code Added to Hide the price                       if (finalPriceWithoutDiscount == 0)
                {
                    pnlHidePrice.Visible = false;
                }

Replicate changes in .ascx files in modules folder in Nopcommerce

    For replicating changes in modules/anyfilename.ascx.cs files, follow the steps below:

1)        Stop IIS and delete Temporary ASP.NET Files form the below location


 C:\WINDOWS\microsoft.net\framework\v2.0.50727\Temporary ASP.NET Files

2)         Open NopCommerceStore as a Project not as a solution or website.
3)         Do the Changes over there
4)         Rebuild It
5)         Publish it
6)         Now Open the NopCommerceStore as WebSite and rebuild the changes
7)     This should work. All the best.