Showing posts with label Godaddy. Show all posts
Showing posts with label Godaddy. Show all posts

June 3, 2011

Ran Out Of Database Space On Godaddy Shared Hosting

I was hosting Nopcommerce On Godaddy server for a client , one day client was trying to upload pictures and got the following error

Could not allocate space for object 'dbo.Nop_Picture'.'Nop_Picture_PK' in database 'nopcomm14demo' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup


The above error occurred because Godaddy has maximum DB space limit  of 1GB and client exceeded that I called Godaddy support, wanted to get a solution from them, asked them to charge extra money and provide more DB Space but they said ,they can't do it on the shared hosting server.




I decided to move the DB with Database Mart.
So first I took the Back Of Database from the Godaddy. 
To  take DB BackUp 
1.) Login to Godaddy A/c 
2.)Go to SqlServer Databases 
3.) click on edit/View Details for your DB




4.) click on BackUp Option


5.) Set Backup folder and Click Ok




6.) Processing Will start but it takes 2-3 hours 


7.) Now Connect to your a/c with FTP client and Download that Database Back Up file on your local hardrive .




8.) Now  I restored this DB On my local machine 


      1.) Login to your Local Sql Server 
      2.) Right click on Databases , clcik On Restore
     3.) Provide new Database Name 
     4.) Select the option From Device , and click the button near to that option



                 5.) It will open up the option to add your .back file , Add the file location , Give file name , Click OK


                   6.) Restoring will be started and After some time Database will be available to the local Machine


9.) Now I have to Export this Data In DatabaseMart Server


10.) I logged on Remotely to that Database Mart Server


11.)Executed NopCommerce script to create the Database.


12) Now I have to Export Data from my machine to there


13) Use Import/Export Wizard 
         1.) Right Click on the Empty DB on Remote Server 
        2.) Go to Tasks--->Import Data


               3.) Follow Wizard steps Choose Local (Source)DB Name , and Select the Database from which you want to export the data.Click Next


             4.)Enter the Destination DB Information 


                 5.) Select Copy Data from Table Option


                      6.) Choose the table you want to Import 


                    7.) Click Edit Mapping and  Check 'Enable identity insert'                                          (http://www.dotnetissues.com/search/label/Import%2FExport%20Wizard%20Sql%20server)


                   8.) Click Ok 


                   9.) Processing will be started ,It takes time as Nop_Picture table has binary data for the image


                  10.) Now Database has been restored on the new server which is providing me 4 GB space




Now  My Databas is on DatabaseMart  server but still the Application is hosted on Godaddy.
I changed ConnectionStrings.config file of the NopCommerce Application and still  was not able to connect to the new DB server
I called Godaddy and figured out that Database Mart is Providing me Database on Port 1087 and Godaddy doesn't allow to connect to other then port 80. So I have now no choice but to move the application hosting also on the Database Mart Server,Which i did and My application is working fine on DatabseMart server and I don't have to worry about DB Space also





October 8, 2010

File Uploader on Godaddy Server C# Code

I wanted to upload a .pdf file from my web Application to my server which is shared server on Godaddy.
I thought to use the FTP Upload so below is the code which I used 



 //public void ftpfile(string ftpfilepath, string inputfilepath)
    //{
    //    string ftphost = "127.0.0.1";
    //    //here correct hostname or IP of the ftp server to be given  


    //    string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
    //    System.Net.FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
    //    ftp.Credentials = new NetworkCredential("username", "password");
    //    //userid and password for the ftp server to given  


    //    ftp.KeepAlive = true;
    //    ftp.UseBinary = true;
    //    ftp.Method = WebRequestMethods.Ftp.UploadFile;
    //    FileStream fs = File.OpenRead(inputfilepath);
    //    byte[] buffer = new byte[fs.Length];
    //    fs.Read(buffer, 0, buffer.Length);
    //    fs.Close();
    //    Stream ftpstream = ftp.GetRequestStream();
    //    ftpstream.Write(buffer, 0, buffer.Length);
    //    ftpstream.Close();
    //}

Above code worked well from my Local machine and I was able to transfer the file to the godaddy hosting server.but the same code when I deployed on server gave the following error

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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: 


[SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +58
   System.Net.FtpWebRequest..ctor(Uri uri) +161
   System.Net.FtpWebRequestCreator.Create(Uri uri) +24
   System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) +216
   System.Net.WebRequest.Create(String requestUriString) +44
   Upload.ftpfile(String ftpfilepath, String inputfilepath) +32
   Upload.btnUpload_Click(Object sender, EventArgs e) +58
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
   System.Web.UI.Page.ProcessRequest() +80
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.upload_aspx.ProcessRequest(HttpContext context) +4
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3053

I tried to change the trust level in web.config file but Godaddy has blocked it you can not make the Hight Trust.
So I left that idea and used the File Uploader Control of ASP.NET 2.0 and below is the code which I wrote on Upload Click Button

 protected void btnUpload_Click(object sender, EventArgs e)
    {
 string filePath = "~/";
        string fileName = FileUpload1.FileName.ToString();
       FileUpload1.SaveAs(Server.MapPath(filePath) + "Test-brochure.pdf");
}


I uploaded the above code and it worked fine and the .pdf file was getting saved with the name Test-brochure.pdf in the root directory.but in this case my pdf file size was 26kb.

but when i gave the 25MB size file I/p .It din't work In Uploading progess bar it went till 15% then again came to 0 and went till 15% and the page has been removed from the server was coming.

I realized that the problem was of file size
so to make it work for the 25MB  file size I added the following node in <system.web> in web.config file

<httpRuntime 
executionTimeout="330" 
maxRequestLength="33792" 
requestLengthDiskThreshold="80" 
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4" 
appRequestQueueLimit="5000" 
enableKernelOutputCache="true" 
enableVersionHeader="true" 
requireRootedSaveAsPath="true" 
enable="true" 
shutdownTimeout="90" 
delayNotificationTimeout="5" 
waitChangeNotification="0" 
maxWaitChangeNotification="0" 
enableHeaderChecking="true" 
sendCacheControlHeader="true" 
apartmentThreading="false" />

basically these two highlighted attributes i increased according to my file size .
default is the below in machine.config
             <httpRuntime maxRequestLength="4096" />

and 
<httpRuntime maxRequestLength="10000" />
will establish a max file upload size of 10,000 Kilobytes.


You can change this attribute according to ur file size
You can set this more broadly in your machine.config, too.