How to generate pkcs12 certificate on windows?
Open a command prompt and go to the bin directory under the installation directory.
For the public certificate type: “openssl req –new –key private-key.pem –x509 –days 365 –out public-cert.pem”
Now it will ask you to enter some information, you can just skip them by pressing [Enter].
Reference: http://docs.ucommerce.net/ucommerce/v6/payment-providers/setup-paypal-standard-website-payments-as-a-payment-method.html
To create the private certificate type: “openssl genrsa –out private-key.pem 1024” and press [Enter].
Now it will ask you to enter some information, you can just skip them by pressing [Enter].
Now we need to create the p12 file. Type the following in the prompt:
“openssl pkcs12 –export –in public-cert.pem –inkey private-key.pem –out
my_pkcs12.p12” followed by [Enter].
Razor Code and Configuration for Umbraco Examine Search
Examine allows you to index and search data easily and wraps the Lucene.Net indexing/searching engine. Lucene is super
fast and allows for very fast searching even on very large amounts of
data. Examine is provider based so is very extensible and allows you to
configure as many indexes as you like and each may be configured
individually. Out of the box our UmbracoExamine library that is shipped with Umbraco gives you Umbraco based implementations for indexers and searchers to get started quickly.
Configuration:
Step 1: Open
the ‘ExamineSettings.config’ file
from the ‘config’ folder.
Step 2: Create
a new Index Provider in the ExamineIndexProviders section:
<add name="MyIndexer" type="UmbracoExamine.UmbracoContentIndexer,
UmbracoExamine"/>
Step 3: Create
a new Search Provider in the ExamineSearchProviders section:
<add name="MySearcher" type="UmbracoExamine.UmbracoExamineSearcher,
UmbracoExamine"/>
Step 4: Open
the ‘ExamineIndex.config’ file from
the ‘config’ folder.
Create a new Index Set in the ExamineLuceneIndexSets section:
<IndexSet SetName="MyIndexSet" IndexPath="~/App_Data/TEMP/MyIndex" />
Code:
@using
Examine;
@{
var searchTerm =
Request.QueryString["search"];
}
<ul class="search-results">
@foreach
(var result in ExamineManager.Instance.Search(searchTerm, true))
{
<li>
<span>@result.Score</span>
<a href="@umbraco.library.NiceUrl(result.Id)">
@result.Fields["nodeName"]
</a>
</li>
}
</ul>
Send Email in Umbraco
Instead using the ASP.Net email sending code, we can use the following code to send email in Umbraco web applications.
<mailSettings>
<smtp>
<network
host="smtp.gmail.com"
port="587"
userName="email@gmail.com"
password="password"
defaultCredentials="false"
enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
<mailSettings>
<smtp>
<network
host="smtp.mail.yahoo.com"
port="465"
userName="email@yahoo.com"
password="password"
defaultCredentials="false"
enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
library.SendMail("from@email.com", "to@email.com", "Subject", "Body", false);
}
Web.Config Configuration:
Gmail SMTP Settings:
<system.net><mailSettings>
<smtp>
<network
host="smtp.gmail.com"
port="587"
userName="email@gmail.com"
password="password"
defaultCredentials="false"
enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
Yahoo Mail SMTP Settings:
<system.net><mailSettings>
<smtp>
<network
host="smtp.mail.yahoo.com"
port="465"
userName="email@yahoo.com"
password="password"
defaultCredentials="false"
enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
Razor:
if (IsPost) {library.SendMail("from@email.com", "to@email.com", "Subject", "Body", false);
}
Solved: Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list
It turns out that this is because ASP.Net was not completely installed with IIS even though I checked that box in the "Add Feature" dialog. To fix this, I simply ran the following command at the command prompt
If I had been on a 32 bit system, it would have looked like the following:
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
If I had been on a 32 bit system, it would have looked like the following:
%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -iReference: StackOverflow
How to set/change the SQL Server 2008 R2 sa’s password after installation?
In this article we will take a look at how to change SA Password in SQL Server
using TSQL code and by using SQL Server Management Studio. The steps mentioned
in this article are applicable to change any SQL Server Login Password works on
SQL Server 2005 and higher versions.
T-SQL Statement:
Use Master
Go
ALTER LOGIN [sa] WITH PASSWORD=N'JJSqlServer', CHECK_POLICY = OFF
Go
T-SQL Statement:
Use Master
Go
ALTER LOGIN [sa] WITH PASSWORD=N'JJSqlServer', CHECK_POLICY = OFF
Go
Generic Handler to Unpublish Past Events in Umbraco
The following Generic Handler (C#) is used to unpublish the past/old Events automatically after it's expiration date in Umbraco.
Source Code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Configuration;
- using umbraco.MacroEngines;
- using umbraco.cms.businesslogic.web;
- namespace KPMGAudit.Web.GenericHandlers
- {
- /// <summary>
- /// Summary description for UnpublishExpiredEvents
- /// </summary>
- public class UnpublishExpiredEvents : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- int EventsNodeId = Convert.ToInt32(ConfigurationManager.AppSettings["EventsNodeId"]);
- string strEventStartDate = string.Empty, strEventEndDate = string.Empty;
- context.Response.ContentType = "text/plain";
- dynamic EventsNode = new DynamicNode().NodeById(EventsNodeId);
- List<DynamicNode> eList = EventsNode.Children.Items;
- foreach (var Event in eList)
- {
- int CurrentEventNodeId = Convert.ToInt32(Event.Id);
- try
- {
- DateTime EventStartDate = Convert.ToDateTime(Event.GetProperty("eventStartDate").Value);
- strEventStartDate = EventStartDate.ToString("MM/dd/yyyy");
- }
- catch { strEventStartDate = string.Empty; }
- try
- {
- DateTime EventEndDate = Convert.ToDateTime(Event.GetProperty("eventEndDate").Value);
- strEventEndDate = EventEndDate.ToString("MM/dd/yyyy");
- }
- catch { strEventEndDate = string.Empty; }
- Document CurrentEventNode = new Document(CurrentEventNodeId);
- if (!string.IsNullOrEmpty(strEventEndDate))
- {
- if (Convert.ToDateTime(strEventEndDate) < DateTime.Now)
- {
- CurrentEventNode.UnPublish();
- }
- }
- else
- {
- if (Convert.ToDateTime(strEventStartDate) < DateTime.Now)
- {
- CurrentEventNode.UnPublish();
- }
- }
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
- public void UnpublishNode(Document CurrentContentNode, DateTime ContentExpiryDate)
- {
- if (ContentExpiryDate != DateTime.MinValue)
- {
- if (Convert.ToDateTime(ContentExpiryDate) < DateTime.Now)
- {
- CurrentContentNode.UnPublish();
- }
- }
- }
Configuration: (umbracoSettings.config)
- <scheduledTasks>
- <!-- add tasks that should be called with an interval (seconds) -->
- <!-- <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>-->
- <task log="false" alias="ExpiredEventsUnpublishScheduler" interval="60" url="http://local.kpmg.com/GenericHandlers/UnpublishExpiredEvents.ashx"/>
- </scheduledTasks>
Thursday, 7 August 2014
Posted by Jebastin
How to Use CDATA in XML?
All text in an XML document will be parsed by the parser.
But text inside a CDATA section will be ignored by the parser.
XML parsers normally parse all the text in an XML document.
When an XML element is parsed, the text between the XML tags is also parsed:
Characters like "<" and "&" are illegal in XML elements.
"<" will generate an error because the parser interprets it as the start of a new element.
"&" will generate an error because the parser interprets it as the start of an character entity.
Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA.
Everything inside a CDATA section is ignored by the parser.
A CDATA section starts with "<![CDATA[" and ends with "]]>":
Code:
A CDATA section cannot contain the string "]]>". Nested CDATA sections are not allowed.
The "]]>" that marks the end of the CDATA section cannot contain spaces or line breaks.
Reference: W3Schools, StackOverflow
XML parsers normally parse all the text in an XML document.
When an XML element is parsed, the text between the XML tags is also parsed:
<message>This text is also parsed</message>The parser does this because XML elements can contain other elements, as in this example, where the <name> element contains two other elements (first and last):
<name><first>Bill</first><last>Gates</last></name>and the parser will break it up into sub-elements like this:
<name>Parsed Character Data (PCDATA) is a term used about text data that will be parsed by the XML parser.
<first>Bill</first>
<last>Gates</last>
</name>
CDATA - (Unparsed) Character Data
The term CDATA is used about text data that should not be parsed by the XML parser.Characters like "<" and "&" are illegal in XML elements.
"<" will generate an error because the parser interprets it as the start of a new element.
"&" will generate an error because the parser interprets it as the start of an character entity.
Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA.
Everything inside a CDATA section is ignored by the parser.
A CDATA section starts with "<![CDATA[" and ends with "]]>":
<script>In the example above, everything inside the CDATA section is ignored by the parser.
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
{
return 1;
}
else
{
return 0;
}
}
]]>
</script>
Code:
- string CDATAStart = "<![CDATA[", CDATAEnd = "]]>";
- LongDescription = CDATAStart + mcLongDescription.Trim() + CDATAEnd;
A CDATA section cannot contain the string "]]>". Nested CDATA sections are not allowed.
The "]]>" that marks the end of the CDATA section cannot contain spaces or line breaks.
Reference: W3Schools, StackOverflow