Joseph Michael Pesch
VP Programming

C# Http Remote Page Post

by 30. August 2013 14:15
NameValueCollection Inputs = new NameValueCollection();
Inputs.Add("param1", "something");
Inputs.Add("param2", "somethingelse");
Http.RemotePost("http://google.com", Inputs);

using System.Collections.Specialized;
using System.Net;

public static class Http
{
  public static void RemotePost(string Url, NameValueCollection Inputs)
  {
    System.Web.HttpContext.Current.Response.Clear();
    System.Web.HttpContext.Current.Response.Write("<html><head>");
    System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", "form1"));
    System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", "form1", "post", Url));
    for (int i = 0; i < Inputs.Keys.Count; i++)
    {
      System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
    }
    System.Web.HttpContext.Current.Response.Write("</form>");
    System.Web.HttpContext.Current.Response.Write("</body></html>");
    System.Web.HttpContext.Current.Response.End();
  }
}

Tags:

C#

Sharepoint PDF Document Prompting User to Checkout when it Shouldn't

by 26. August 2013 15:54

We had issues with PDF documents on Sharepoint that were prompting the average "View Only" users to check-out the document.  If they actually attempted to check-out the document they could not; however, this was cofusing to the users.  The desired effect was to have the document open directly into the PDF viewer.  Below are some registry settings that seemed to clear this issue up in most cases.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Adobe Acrobat\11.0\FeatureLockDown\cSharePoint]
"bDisableSharePointFeatures"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Adobe Acrobat\10.0\FeatureLockDown\cSharePoint]
"bDisableSharePointFeatures"=dword:00000001

Tags:

Sharepoint

SQL DBCC ShrinkFile Not Working (i.e. Executes Successfully But File Does Not Shrink)

by 22. August 2013 12:41

When attempting to run "DBCC ShrinkFile" SQL command to shrink a transaction log file on a database that has replication enabled it may appear to have run successfully; however, the log file may not actually shrink.  To resolve this issue you can add a call to "EXEC sp_repldone" to allow the server to take action on the log file.  Below is a sample process that I have added to a nightly job to take place after the full DB backup executes.

use DBName;
go
alter database DBName set recovery simple;
go
exec sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @time = 0, @reset = 1
go
dbcc SHRINKFILE (DBName_log, 1);
go
alter database DBName set recovery full;
go

Tags:

SQL Server

Wordpress 404 Error When Using Permalinks /%postname%/

by 19. August 2013 20:43

Put the following content in the .htaccess file in the root folder:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

 Add Rewrite to web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <directoryBrowse enabled="false" />
    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php/{R:0}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Tags:

PHP | Wordpress