Hope this helps someone.
mrvautin
Saturday, 15 June 2013
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
While this error could very mean you are hosting in a cluster and the machine key differs from server to server. If you are hosting on a single machine it is good to check that if you are not submitting the <form> that you don't have an action (eg action=default.aspx). This can cause the error and whilst a simple thing, it can easy be missed in the answers received in googling the error.
Labels:
.NET,
c#,
cluster,
machinekey,
validation of mac,
viewstate
Thursday, 7 March 2013
Convert HTML or a Website to an image file (C#)
I was looking around for hours looking for the ability to create an image from some HTML I'd scraped from a Website. Note: This solution also works for Websites which are publicly accessible to don't require authentication.
It essentially dynamically sets up a WebBrowser control, loads a URL (waits for it to be completely loaded) and takes an image of the rendered HTML. The solution below creates an image which is the full size of the rendered HTML. You can add padding to the image by adding pixels to the "wb.Width" and "wb.Height" values.
It's quite simple really. Here is the function to render the HTML:
You can call it by:
Notes: You can also use "C:\test.html" rather than "www.google.com" and you can change the output file by adjusting the "ImageFormat" value.
That's it.
It essentially dynamically sets up a WebBrowser control, loads a URL (waits for it to be completely loaded) and takes an image of the rendered HTML. The solution below creates an image which is the full size of the rendered HTML. You can add padding to the image by adding pixels to the "wb.Width" and "wb.Height" values.
It's quite simple really. Here is the function to render the HTML:
public Bitmap GenerateScreenshot(string url)
{
// Load the webpage into a WebBrowser control
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
// waits for the page to be completely loaded
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
// Take Screenshot of the web pages full width + some padding
wb.Width = wb.Document.Body.ScrollRectangle.Height;
// Take Screenshot of the web pages full height
wb.Height = wb.Document.Body.ScrollRectangle.Height;
// Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}
You can call it by:
Bitmap thumbnail = GenerateScreenshot("www.google.com");
thumbnail.Save("C:\image file.bmp", ImageFormat.Bmp);
Notes: You can also use "C:\test.html" rather than "www.google.com" and you can change the output file by adjusting the "ImageFormat" value.
That's it.
Thursday, 28 February 2013
St.George Opencart 1.5+ XML webservice module
St.George Opencart 1.5+ XML module
You can download the module here.
Note: You will have to generate a Authentication Token for your merchant account to use this module. This is done through:
Merchant Administration Console > IPG Accounts > Authentication (tab) > Security Token > Configure
Labels:
IPG,
module,
Opencart,
payment gateway,
POST,
shopping cart,
St.George Bank,
Webservice,
xml payment
Tuesday, 22 January 2013
iPhone 5 - 6.1 untethered jailbreak - Update 2
With the release of iOS 6.1 coming closer, more speculation about the release of an untethered Jailbreak for 6.x devices and particularly the iPhone 5.
Just today @PlanetBeing, who is known to be working on the new jailbreak tweeted this:
We are not sure right now what the reference to the "future" is. Maybe he has found a bootrom exploit which was found older devices which meant they always had a leg in no matter what iOS version the device was running.
With any luck, we should have a jailbreak for our iPhone 5's and iOS 6.x devices real soon! Stay tuned for updates.
UPDATE: @pod2g has tweeted daring Apple to release iOS 6.1 so the new jailbreak can be released to the public.
UPDATE 2: With the official release of iOS 6.1 today, @MuscleNerd has tweeted hinting at a Sunday (Super Bowl) release. Thinking are looking up. He also said to stay tuned to the @evad3rs twitter account for further updates.
UPDATE: @pod2g has tweeted daring Apple to release iOS 6.1 so the new jailbreak can be released to the public.
UPDATE 2: With the official release of iOS 6.1 today, @MuscleNerd has tweeted hinting at a Sunday (Super Bowl) release. Thinking are looking up. He also said to stay tuned to the @evad3rs twitter account for further updates.
Labels:
Apple,
evad3rs,
iOS 6,
iPhone,
iPhone 5,
jailbreak,
MuscleNerd,
planetbeing,
pod2g,
untethered
Thursday, 10 January 2013
Ubuntu Appcelerator Titanium Studio - Error ".titanium/mobilesdk/linux/3.0.0.GA/android/builder.py"
I wasted way too much of my life trying to figure out how to fix the ".titanium/mobilesdk/linux/3.0.0.GA/android/builder.py" error when setting up Appcelerator Titanium Studio on Ubuntu to not share it. This is the one step that got me as it doesn't appear to be documented anywhere nor is it easy to find when googling.
To fix the error:
To fix the error:
$ sudo apt-get install ia32-libsNote: You will also need to ensure you have Java JDK version 6 (aka 1.6) not any version greater or less. It is a requirement of Titanium Studio to have this specific JDK version.
Tuesday, 8 January 2013
C# Sending files to an application using the Windows Explorer "Send To" function
I was recently writing an app (which I will post the source to soon) which required the ability for the user to have a right-click type menu from Windows explorer. Adding right click menu's in Windows explorer sounded not only hard but not very future proof across different versions of Windows. I decided to go down the "SendTo" path, where the user can right click and select the application from the "Send To" menu. There are advantages with this approach as it doesn't require the application to be open, meaning we don't have to run it at start-up and doesn't require any dodgy "hackery" to get a right-click context menu in Windows explorer.
The gist of the solution is this. A normal Windows shortcut is created in the "logged in" users "SendTo" folder. When the user right-clicks one or multiple files, selects "Send To" and there is my app just waiting for some file paths... When the app loads, Windows passes the files paths to the app as some args, my app collects the files and does its magic with them.
Its achieved like this:
1. First we are going to create the shortcut for the "Send To" menu.
1.1. Add the COM object to create Windows shortcuts - "Windows Script Host Object Model"
1.2. We then create the shortcut. I do it on form load as the app will not be installed and the exe might get moved. I also had dramas checking whether the shortcut already exists using a "File.Exists()". If anyone has any idea why let me know. It always returned "false".
2. I chose to use a public string[] to hold my file paths to be used throughout my app (In particular, my Form_Load()).
The gist of the solution is this. A normal Windows shortcut is created in the "logged in" users "SendTo" folder. When the user right-clicks one or multiple files, selects "Send To" and there is my app just waiting for some file paths... When the app loads, Windows passes the files paths to the app as some args, my app collects the files and does its magic with them.
Its achieved like this:
1. First we are going to create the shortcut for the "Send To" menu.
1.1. Add the COM object to create Windows shortcuts - "Windows Script Host Object Model"
1.2. We then create the shortcut. I do it on form load as the app will not be installed and the exe might get moved. I also had dramas checking whether the shortcut already exists using a "File.Exists()". If anyone has any idea why let me know. It always returned "false".
2. I chose to use a public string[] to hold my file paths to be used throughout my app (In particular, my Form_Load()).
public partial class Form1 : Form
{
// Setup the public string
public string[] file_args;
public Form1(string[] args)
{
InitializeComponent();
// Set the public string[] with the args received by the form
file_args = args;
}
}
3. In my "Program.cs" file I receive the string[] args and pass them to the Form1
static class Program
{
///
///
/// The main entry point for the application.
///
///
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(args));
}
}
4. In the Form_Load()event or wherever you can simply use the file_args variable. Eg:
// If there are some files passed
if (file_args.Length > 0)
{
foreach (string file in file_args)
{
// Do something here
}
}
Friday, 4 January 2013
iPhone 5 - 6.0.2 untethered jailbreak
Famous iPhone hacker "planetbeing" has announced today on reddit that he has an untethered iOS 6.0.2 jailbreak running on his iPhone 5. He has said it will be a released in due time but is most likely holding out for next iOS release before giving it to the public. Good news for everyone waiting for an iOS 6.x.x jailbreak!
Source: iDownloadblog
Source: iDownloadblog
Labels:
Apple,
iOS 6,
iPhone,
iPhone 5,
jailbreak,
planetbeing,
untethered
Subscribe to:
Posts (Atom)




