Friday, February 13, 2009

asp:HyperLink NavigateUrl Problem Absolute URL

I came across an idiotic problem with asp:HyperLink control.
What happened is that I noticed every time I bind a hyperlink NavigateURL field in code-behind, it points to current site + the url i specifed.

Example:

In Page_Load i do:

lnkAbsolute.NavigateURL = "http://www.google"

But the result on the page is

http://www.mysite.com/www.google.com

IDIOTIC


Solution

So the solution i found is not relay good but nevertheless a solution.

I saw that in Page_PreRened event my NavigateURL lost "http://" part of the URL
so you just have to re-add the "http://" prefix to the URL in Page_PreRender event, like so:

protected void Page_PreRender(object sender, EventArgs e)
{
if (!lnkAbsolute.NavigateUrl.StartsWith("http://") && !string.IsNullOrEmpty(lnkAbsolute.NavigateUrl))
{
lnkAbsolute.NavigateUrl = "http://" + lnkAbsolute.NavigateUrl;
}
}


Sometimes I just can believe how the simplest of things can hold you back.

Thursday, February 12, 2009

ASP.NET vs PHP. Top 5 sites running ASP.NET or IIS servers

Hi to all developers,

I decided to write this post after 100th time I had to defend the technology i choose to work on (which is ASP.NET). Often when somebody(client) decides what to use for their web site he asks around and they get an answer like
"Use PHP it is the best!!! Do not use ASP.NET it is expensive and not safe".
That is a incorrect generalization and often suggested by people working on PHP.


Then that somebody (usually the client) demands me to prove that ASP.NET is a viable framework for developing web application. And after the 100th time(Repetition is the mother of knowledge) I had to write a mail to explain that ASP.NET is a proven framework for developing web apps here is what i come up with:

Web Servers
There is a place on the web news.netcraft.com/ that can show you witch site use what web server, among other things. Latest data (Jan 2009) show:

Apache 52.26%
Microsoft 32.91%

So one third of all the web servers out there a hosted on Microsoft servers and probably most of the use ASP.NET.

Hosting
When I say hosting I mean dedicated or virtual server hosting and most of the hosting providers on the web that offer both Linux and Microsoft servers have the same price difference.

Usually Windows servers is 20% more expensive than Linux.

If you take that the average price for an average server on the web is around $150 a month the price difference is not really a problem.

Top 5 sites running ASP.NET or Microsoft/IIS servers
So I used Alexa The top 100 sites in the English language and searchdns.netcraft.com to get to top 5 sites that either are running on IIS and/or ASP.NET (I excluded all Microsoft sites)

www.orkut.com - 9th place. Social networking and discussion site operated by Google. I dose run on Linux but as far as I see it the extensions of url's on that sites is .aspx and that is ASP.NET (Correct me if I'm wrong
www.ebay.com 13th place. Uses Windows servers.
www.espn.go.com 35th place
www.doubleclick.com 73th place. Coordinates targeted Internet advertising campaigns for advertisers, and provides ad management services, software, and sales for publishers. At least they corporate website is running on ASP.NET.
www.imeem.com 82th place. Users interact with each other by watching, posting, and sharing content of all media types, including blogs, photos, audio, and video.

Also www.godaddy.com is one of the biggest domain registrar out there with around 26% global market share, running on ASP.NET . Source http://www.webhosting.info/registrars/reports/total_domains/GODADDY.COM?ob=gs&oo=asc

I'm sure i made some errors in the list but I'm also sure there are many other popular, highly visited and secure web sites out there that run on ASP.NET.

So to finish with this.

The security, speed and stability of a web site or application is not determined by the technology or the server used, but the quality and knowledge of people developing it.

I said Good Day Sir.

Wednesday, April 23, 2008

DotNetNuke custom modules in C#, develop and debug

So for my first blog entry I decided to share my expertise with developing DotNetNuke custom modules in C#.

When I was deciding on architecture for one big DotNetNuke based project I wanted to create custom modules in C# but I had a problem of creating solution i Visual Studio that could be easily debugged and did not require manual coping of *.ascx files.

We used "DotNetNuke C# Compiled Module" that can be downloaded at THIS address

Anyway we had a problem of continuous development, debug and manual copying of the files

So we used Visual Studio projects "Pre build event" property in order to integrate custom module in to DNN solution.

HOW IT WORKS?
  • Create a solution and add DNN as a web site (lets say the DNN folder is "SolutionDir\DNN")
  • Add you custom DNN C# module project
  • Go to the custom module project properties (right click on project etc.)
  • Go to "Build Events"
  • Click "Edit pre-builde..."
  • Insert this script in to the dialog window
rd /S /Q "$(SolutionDir)DNN\DesktopModules\$(ProjectName)"
md "$(SolutionDir)DNN\DesktopModules\$(ProjectName)"
md "$(SolutionDir)DNN\DesktopModules\$(ProjectName)\App_LocalResources"

copy "$(ProjectDir)App_LocalResources\" "$(SolutionDir)DNN\DesktopModules\$(ProjectName)\App_LocalResources"
copy "$(ProjectDir)*.ascx" "$(SolutionDir)DNN\DesktopModules\$(ProjectName)"
copy "$(ProjectDir)*.dnn" "$(SolutionDir)DNN\DesktopModules\$(ProjectName)"
copy "$(ProjectDir)uninstall.*" "$(SolutionDir)DNN\DesktopModules\$(ProjectName)"

What dose this do?
Every time you do a build of the solution you this script will remove the module directory from /DesktopModules/ then create it again with /App_LocalResources/ sub folder, copy all the resx, ascx, dnn and uninstall files to you /DesktopModule/ folder

Restrictions and pitfalls
  • In this scenario your DotNetNuke folder is /DNN/ if it's different just replace "DNN" in the script with your own folder name.
  • Also name of the project must be the same as the module definition name of the folder in DNN if it's different just replace $(ProjectName) with the name of your folder.
  • Also you should put the build path for your custom module in DNN/bin folder
Conclusion
In this way you can use your module as separate project debug them and create a solution that has logical structure.

Write comments I will help you with your problems, I'm that good.

Special tnx to Curia Damiano

DotNetNuke Outsourcing