CodeCopy

November 14, 2013

IIS Express 64Bit ( Visual Studio 2012 )

Filed under: c# — mazzoo @ 12:55

To enable 64Bit Web projects in Visual Studio 2012 via IIS Express, run the following command.

reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\WebProjects /v Use64BitIISExpress /t REG_DWORD /d 1

And restart Visual studio.

February 22, 2013

Ghost IFrame (CrossDomain IFrame resize)

Filed under: c# — mazzoo @ 13:49

It is possible to get an iframe to react and auto adjust simply like it is not there in CrossDomains situations.

This solution is tested on IE8,9,10 and Chrome and Firefox.

Only requirement – you have to have know which server that implements the iframe.

To achieve this – we needed a communication channel between the two pages. To do this we used the javascript messaging system.

IFrame content script:


$(window).load(function ()
{
    UpdateDimensions();
});

function UpdateDimensions()
{
try
{
var height = $("#form1").height() + 30;
var width = $(".SiteIntegrationSizePanel").outerWidth() + 100;

if (window.postMessage && ReferalUrl != undefined)
parent.postMessage(height + "," + width, ReferalUrl);
}
catch (c)
{
alert(c.message);
}
}

The SiteIntegrationSizePanel class is a fixed width container. That can vary from page to page.

Rerferal url is the domain that hosts the IFrame.

Described here https://developer.mozilla.org/en-US/docs/DOM/window.postMessage

Host site:


if (window.addEventListener)
{
window.addEventListener('message', OnLoadPage, false);
}
else if (window.attachEvent)
{
window.attachEvent('message', OnLoadPage);
}

function OnLoadPage(event)
{
var iframe = document.getElementById(‘SiteIntegrationIFrame');
if (event.data.indexOf(",") > 0)
{
var height = event.data.split(",")[0];
var width = event.data.split(",")[1];

iframe.height = parseInt(height);
iframe.width = parseInt(width);
}

window.scrollTo(0, 0);
}

The SiteIntegrationIFrame id is the IFrame

December 6, 2012

Remove ugly IE selection dotted border from inputs

Filed under: c# — mazzoo @ 14:15

Add the following CSS to remove the dotted selection border in IE.

textarea,
input,
a,
a:hover,
a:active,
a:focus
{
    outline: 0px!important;
}

November 21, 2012

Web Api enum serialization

Filed under: c#,Web Api — sterndorff @ 07:53

In a MVC WebApi application, all enums are default serialized to their integer representation.

Want to serialize all enums to name instead?

Put in Global.asax:

JsonSerializerSettings jSettings = new JsonSerializerSettings();
jSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = jSettings;

September 19, 2012

Cisco AnyConnect VPN Client fails on Windows 8

Filed under: Cisco,Windows 8 — sterndorff @ 05:04

If Cisco AnyConnect VPN software fails to connect on Windows 8 it may be because the name is incorrect in registry.

  • Goto “Control panel” -> “Network and Sharing Center” -> “Network Connections”.
  • Right click on the installed connection profile (on my computer “Cisco AnyConnect VPN Client Connection”) and choose Properties.
  • Copy the name from “Connect using” (on my computer “Cisco AnyConnect VPN Virtual Miniport Adapter for Windows x64”).

Use that name as “DisplayName” in registry:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vpnva]
“DisplayName”=”Cisco AnyConnect VPN Virtual Miniport Adapter for Windows x64”

September 11, 2012

asp.net checkbox check/uncheck all with JQuery

Filed under: asp.net,JQuery — sterndorff @ 09:29

html:

<asp:CheckBox CssClass="ChooseAll" Text="Choose all" runat="server" /><br />
<asp:CheckBox CssClass="CheckBoxItem" Text="Checkbox 1" runat="server" /><br />
<asp:CheckBox CssClass="CheckBoxItem" Text="Checkbox 2" runat="server" /><br />
<asp:CheckBox CssClass="CheckBoxItem" Text="Checkbox 3" runat="server" /><br />

jquery:

$(document).ready(function () {
     $(".ChooseAll input:checkbox").change(function ()
     {
         var checked = $(this).attr('checked') || false;
         $(".CheckBoxItem input:checkbox").attr('checked', checked);
     });

     $(".CheckBoxItem input:checkbox").change(function ()
     {
         var checked = ($(".CheckBoxItem input:checked").length == $(".CheckBoxItem input:checkbox").length);
         $(".ChooseAll input:checkbox").attr('checked', checked);
     });
});

August 31, 2012

Disable UAC in Windows 8

Filed under: Windows 8 — sterndorff @ 10:25

If you have problems compiling or publishing from Visual Studio 2012 on Windows 8 it may be because UAC is not fully disabled. It is not enough to set UAC to “Never notify”.

Edit in regedit:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

Key: EnableLUA
Value: 0

 

(Note that you are not able to run metro apps when this hack is done)

July 10, 2012

VPN fails on ASA Box

Filed under: Cisco — mazzoo @ 20:46

If your ASA box suddenly blocks all personal VPN calls from your clients, and you are getting a VPN 619 Error. And firewall logs in the line of “Teardown dynamic TCP translation…”

Try to fire this command: “fixup protocol pptp 1723”

This will fix the error instantly !

March 13, 2012

That’s why I fear them !

Filed under: c# — mazzoo @ 14:49

angry-panda

March 12, 2012

Keep it alive !

Filed under: c# — mazzoo @ 23:49

We have all been there. After a Hard Days Night, with a cup of Joe and a long day ahead of you.

The last thing you need is to wait for the IIS to wake up.

This can be avoided in a couple of ways. Either by buying expensive crappy software, or by running custom scripts.

That’s all fine and good, but why not implement the functionality right into the ASP.NET app itself. That’s exactly what we will do Smile

In the Application_Start() function ( inside the Global.asax ) put the following code:


protected void Application_Start(object sender, EventArgs e)
{
KeepAlive.KeepISSAlive();
}

public static class KeepAlive
 {
public static void KeepISSAlive()
{
// Remove any existing job
Action existingAction = HttpContext.Current.Cache["KeepIISAlive"] as Action;
if (existingAction is Action)
{
HttpContext.Current.Cache.Remove("KeepIISAlive");
existingAction.EndInvoke(null);
}

Action work = () =>
{
while (true)
{
Thread.Sleep(60000);

WebClient keepIISAlive = new WebClient();
try
{
keepIISAlive.UploadString("YourUrl.com", string.Empty);
}
catch (Exception exception)
{
}
finally
{
keepIISAlive.Dispose();
}

}
};
work.BeginInvoke(null, null);

// Add the action to the cache instance
HttpContext.Current.Cache.Add(
"KeepIISAlive",
work,
null,
Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration,
CacheItemPriority.Normal,
(key, value, reason) => { KeepISSAlive(); }
);
}
}

Hope it helps !

Thanks to webdev_hb for this great hint !

Next Page »

Create a free website or blog at WordPress.com.