Get Alexa Ranks With Class in ASP.Net

by kad1r 1. March 2010 10:58
public class AlexaData
{
public DataTable pro(string domain)
{
DataTable tablo = new DataTable();
string url = "http://alexa.com/xml/dad?url=" + domain;
XmlDocument doc = new XmlDocument();
doc.Load(url);
string owner = "", popularity = "";
DataRow r = tablo.NewRow();
if (doc.SelectSingleNode("//OWNER") != null)
{
owner = doc.SelectSingleNode("//OWNER").Attributes[0].InnerText;
tablo.Columns.Add("OWNER");
r[0] = owner;
}
if (doc.SelectSingleNode("//POPULARITY") != null)
{
popularity = doc.SelectSingleNode("//POPULARITY").Attributes[1].InnerText;
tablo.Columns.Add("POPULARITY");
r[1] = popularity;
}
tablo.Rows.Add(r);
return tablo;
}
}

Google Analytics API using with ASP.Net

by kad1r 27. February 2010 13:12
Google Analytics API integration with Asp.net application
string userName = ""; // Enter your username
string passWord = ""; // Enter your password
const string dataFeedUrl = "https://www.google.com/analytics/feeds/data";
AccountQuery query = new AccountQuery();
AnalyticsService service = new AnalyticsService("AnalyticsSampleApp");
if (!string.IsNullOrEmpty(userName))
{
service.setUserCredentials(userName, passWord);
}
string str = "";
AccountFeed accountFeed = service.Query(query);
foreach (AccountEntry entry in accountFeed.Entries)
{
str = entry.ProfileId.Value;
}

 

DataQuery query1 = new DataQuery(dataFeedUrl);
query1.Ids = str;
query1.Metrics = "ga:visits";
query1.Sort = "ga:visits";
query1.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("yyyy-MM-dd");
query1.GAEndDate = DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd");
query1.StartIndex = 1;
DataFeed dataFeedVisits = service.Query(query1);
foreach (DataEntry entry in dataFeedVisits.Entries)
{
string st = entry.Title.Text;
string ss = entry.Metrics[0].Value;
_intVisists = Int32.Parse(ss);
Response.Write("
");
Response.Write("Total Visits : " + ss);
Response.Write("
");
}

W3C Validation and ImageButton Problems in ASP.Net

by kad1r 20. February 2010 13:27

If you are developing website with asp.net and generally you use ImageButton (I'm always using ImageButton and I love it) when you validate your website in W3C you get an error for border="0". You can't fix it. Yesterday I was crazy about that. But there is a solution and it's easy and simple. Just replace your ImageButton to LinkButton and then put image for your button. I mean:

<asp:LinkButton ID="lnkBtn" runat="server"><img alt="myButton" src="bla bla..." /></asp:LinkButton>

ASP.Net and Seo Friendly Websites

by kad1r 18. February 2010 12:39
As you know seo is very important for websites. If you didn't optimize your website users can't find you.
ASP.NET offers is robust server side scripting language which offers several advantages and also helps us to create Search Engine Friendly Content Managed Websites. Sitemaps, meta, title ..etc are important. And ofcourse urlrewriting is very important! Don't forget.

Here is the source for developing seo friendly webpages with ASP.Net. Click to see article and enjoy.

Get IP Address and Machine name in ASP.Net

by kad1r 15. February 2010 20:42
Get machine name: Request.ServerVariables["REMOTE_HOST"]
Get IP Address: Request.ServerVariables["REMOTE_ADDR"]
Sometimes both can return IP address. In this situation use Split(System.Net.Dns.Resolve(Request.ServerVariables("remote_addr")).HostName, ".") or System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' })

Firefox login problem with sessions

by kad1r 12. February 2010 14:20

I have a little login problem with Firefox in ASP.Net.
If you are using Response.Redirect("Default.aspx", false); don't use "false" statement. Because Firefox sometimes clear or down the session. So after login you can't get session value and you will never login the system.
Always use Response.Redirect("Default.aspx");.
Have fun...

Here is the exact explanation.

ASP.Net Html Post Security

by kad1r 11. February 2010 12:28

If you're using any editor like Fck, Tinymce ..etc sometimes you get potentially dangerous form value error. It says this is dangerous but sometimes it's not dangerous. When you trust your codes and want to remove this error you need to add to ValidateRequest="false". This code just for adding page. If you want to remove all you need to add <pages validateRequest="false" /> to web.config file between system.web tags.

 

ASP.Net MVC 2 RC2 Released

by kad1r 10. February 2010 09:38
I read on the Phil's blog. In december RC was released. Now after feedbacks they released RC2. Here is the release notes.
Phil says the biggest change is input and model validation. Other article about input validation and model validation is in Brad Wilson's blog.

Tags: , ,

ASP.Net | MVC | Released

Get Mac Address in ASP.Net

by kad1r 9. February 2010 10:18
This is really useful snipet for getting Mac address.
But first you need to add reference to System.Management.

public string GetMACAddress()
    {
        ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
        ManagementObjectCollection moc = mc.GetInstances();
        string MACAddress = String.Empty;
        foreach (ManagementObject mo in moc)
        {
            if (MACAddress == String.Empty)
            {
                if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
            }
            mo.Dispose();
        }
 
        MACAddress = MACAddress.Replace(":", "");
        return MACAddress;
    } 

ASP.Net vs PHP and others

by kad1r 31. January 2010 23:26
Everytime I tell ASP.Net is very powerful and fast. Yes ofcourse PHP is also fast but not powerful like ASP.Net. PHP has a very big documentation and it has too many users.
Here is the ASP.Net and PHP comparison.
 

So, ASP.Net is faster than PHP ;)

Tags: , ,

ASP.Net | Live



Powered by BlogEngine.NET 1.5.0.7
Keywords: MVC, ASP.Net, Csharp, visual tutorials, SQL, Ubuntu
VisualStudio.Gen.Tr

Widgets

Follow kad1r on Twitter
ÇözümPark

Wordle

kad1r.com - wordle