Monday, October 26, 2009
User Account Control Settings in Windows 7
The tool is accessible through the ControlPanel->AllControlPannelItems->ActionCenter->ChangeAccountControlSettings
Friday, October 23, 2009
Test Your Pages
- HTTPFox : obviously for FireFox, but not available for new version of FF at this time :-(
- HttpWatch a free tool (can upgrade to professional) works on both IE8 and FF as addin. It rocks
- www.webpagetest.org a free website that tests your page from a remote location. They provide three remote location to initiate the test which makes your test very natural.
Wednesday, October 21, 2009
Run As Administrator
runas /user:Administrator MyApp
For things like Cisual Studio 2008 you can change the properties of the shortcut, and in the Advanced Properties check the Run as administrator checkbox.
VS 2008 JavaScript Intellisense
http://weblogs.asp.net/scottgu/archive/2007/06/21/vs-2008-javascript-intellisense.aspx
Friday, September 25, 2009
How to stick the footer to the buttom of the page
div#footer
{
clear: both;
padding: .5em 1em;
border-top: 0px solid #ccc;
text-align: center;
padding: 0 0 0 0;
margin: -20px 0 0 -100px;
position: fixed;
left : 50%;
top: 100%;
}
Monday, September 21, 2009
IIS Url Forwarding
<urlmappings enabled="true"><blockquote><p><urlmappings enabled="true">
<add mappedurl="~/default.aspx?parm1=1" url="~/home">
<add mappedurl="~/Products.aspx" url="~/products">
<add mappedurl="~/Product.aspx?id=1" url="~/product">
</urlmappings>
How do I secure my browser - Part
I. Tell your browser never go to that domain.
II. let your router know that this domain should be filtered.
Although the second way is enough to stop the worm but I thought some people might not have the feature in their router to do that, so I also mentioned the first one.
1. In the Internet Explorer go to Menu Tools->Internet Options and when the Internet Options pops up click on the Security tab.
2. You will see different zones. The important zone is : Restricted sites. Click on it.
3. Once you selected the Restricted sites click on the Sites button. This will pop up another window called Restricted Sites which holds a list of sites that you don't want your browser coincidently or willingly go there.
4. In th text box under "Add this site to the zone:" type the following:
*.secure-logins.com
5. Press the Add button and you will see that the address is added to the list
6. Press the Close button and you will be back to the Internet Options.
7. Click OK,
that's it
My router is a D-Link and have an option to filter any requests going to a specific address from any machine at my home. You should check your router's website which is often to e accessed by http://192.168.0.1
In the Advanced menu you will find a link to go to Website Filter. When you get there you will see an empty list where you can add your preferences. The 'Website Filter' option allows you to set up a list of Web sites you would like to deny through your network.
Add the same address there:
thats all.
Friday, August 21, 2009
Tip To Log
Trace.WriteLine("Beginning with " + System.Reflection.MethodInfo.GetCurrentMethod().Name);
it will work just fine
Monday, August 10, 2009
Linq-To-SQL and WCF
To sort out this problem we need attach the instance record again to the list in the context:
context.GetTable
just before we call the SubmitChanges. But this is not always possible. I got the following error when calling this:
An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy.
The simple way of sorting this out was giving the ID field of the record the attribute of
IsVersion=true
This way Linq allows me to attach the existing instance and generate an UPDATE sql-statement.
See Also: http://www.west-wind.com/Weblog/posts/135659.aspx
Wednesday, July 15, 2009
Using Linq-To-SQL classes as DataContract in WCF
He describes the trick to get the Link-To-SQL data classes generated to be consumed as DataContract. In his document he points out that you need to set the Serialization Mode property of the dbml surface to Unidirectional.
Friday, July 10, 2009
Common Buses and their Max Bandwidth
Bandwidth
PCI Express in all it's flavors: 1x, 2x, 4x, 8x, 16x and 32x all have much greater bandwidth than basic PCI.
Common Buses and their Max Bandwidth
PCI 132 MB/s
AGP 8X 2,100 MB/s
PCI Express 1x 250 [500]* MB/s
PCI Express 2x 500 [1000]* MB/s
PCI Express 4x 1000 [2000]* MB/s
PCI Express 8x 2000 [4000]* MB/s
PCI Express 16x 4000 [8000]* MB/s
PCI Express 32x 8000 [16000]* MB/s
IDE (ATA100) 100 MB/s
IDE (ATA133) 133 MB/s
SATA 150 MB/s
Gigabit Ethernet 125 MB/s
IEEE1394B [Firewire] 100 MB/s
Tuesday, June 16, 2009
using UriTemplate
The UriTemplateTable class provides a mechanism for managing a collection of UriTemplate objects. This makes it easy to call Match on the table to find all templates that match the supplied Uri. Alternatively, you can call MatchSingle to ensure it matches only a single UriTemplate in the table.
Uri baseUri = new Uri("http://contoso.com/bookmarkservice");
UriTemplate uriTemplate = new UriTemplate( "users/{username}/bookmarks/{id}");
// generate a new bookmark URI
Uri newBookmarkUri = uriTemplate.BindByPosition(baseUri, "skonnard", "123");
// match an existing bookmark URI
UriTemplateMatch match = uriTemplate.Match(baseUri, newBookmarkUri);
System.Diagnostics.Debug.Assert(match != null);
Console.WriteLine(match.BoundVariables["username"]);
Console.WriteLine(match.BoundVariables["id"]);
Friday, March 27, 2009
Catch the Session Expired case
void Application_AcquireRequestState(object sender, EventArgs e)
{
if (HttpContext.Current.Session != null && HttpContext.Current.Session.IsNewSession)
{
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies["ASP.NET_SessionId"] != null)
{
HttpContext.Current.Session.Clear();
HttpContext.Current.Response.Redirect("/Errors/SessionTimeout.aspx", true);
}
}
}
}
EnableSessionState="False"
Friday, March 20, 2009
URL properties of Request to ASP.NET
http://localhost/Test/Asghar.aspx?test=fine
And I get the following results:
AbsolutePath = /Test/Asghar.aspx
AbsoluteUri = http://localhost/Test/Asghar.aspx?test=fine
Authority = localhost
DnsSafeHost = localhost
Fragment =
Host = localhost
HostNameType= Dns
IsAbsoluteUri = True
IsFile = False
LocalPath = /Test/Asghar.aspx
OriginalString = http://localhost:80/Test/Asghar.aspx?test=fine
PathAndQuery = /Test/Asghar.aspx?test=fine
Port = 80
Query = ?test=fine
Scheme = http
UserEscaped = False
UserInfo =
And the code to do it is as followes:
AbsolutePath = <%= System.Web.HttpContext.Current.Request.Url.AbsolutePath %><br />
AbsoluteUri = <%= System.Web.HttpContext.Current.Request.Url.AbsoluteUri %><br />
Authority = <%= System.Web.HttpContext.Current.Request.Url.Authority %><br />
DnsSafeHost = <%= System.Web.HttpContext.Current.Request.Url.DnsSafeHost %><br />
Fragment = <%= System.Web.HttpContext.Current.Request.Url.Fragment %><br />
Host = <%= System.Web.HttpContext.Current.Request.Url.Host %><br />
HostNameType= <%= System.Web.HttpContext.Current.Request.Url.HostNameType.ToString() %><br />
IsAbsoluteUri = <%= System.Web.HttpContext.Current.Request.Url.IsAbsoluteUri %><br />
IsFile = <%= System.Web.HttpContext.Current.Request.Url.IsFile %><br />
LocalPath = <%= System.Web.HttpContext.Current.Request.Url.LocalPath %><br />
OriginalString = <%= System.Web.HttpContext.Current.Request.Url.OriginalString %><br />
PathAndQuery = <%= System.Web.HttpContext.Current.Request.Url.PathAndQuery %><br />
Port = <%= System.Web.HttpContext.Current.Request.Url.Port %><br />
Query = <%= System.Web.HttpContext.Current.Request.Url.Query %><br />
Scheme = <%= System.Web.HttpContext.Current.Request.Url.Scheme %><br />
UserEscaped = <%= System.Web.HttpContext.Current.Request.Url.UserEscaped %><br />
UserInfo = <%= System.Web.HttpContext.Current.Request.Url.UserInfo %><br />
<hr />
Saturday, January 31, 2009
Read CSV file into LINQ
using (StreamReader reader = new StreamReader("books.csv"))
{
var books =
from line in reader.Lines()
where !line.StartsWith("#")
let parts = line.Split(',')
select new {
Title = parts[1],
Publisher = parts[3],
Isbn = parts[0]
};
// use the books here ...
}
Join And Group Tables
Group Join
from publisher in SampleData.Publishers
join book in SampleData.Books
on publisher equals book.Publisher into publisherBooks
select new { Publisher=publisher.Name, Books=publisherBooks };
This is a group join. It bundles each publisher's book as sequences named publisherBooks. This new query is equivalent to this one:
from book in SampleData.Books
group book by book.Publisher into publisherBooks
select new { Publisher=publisherBooks.Key.Name, Books=publisherBooks };
Inner Join
An inner join essentially finds the intersection between two sequences. With an inner join, the elements from two sequences that meet a matching condition are combined to from a single sequence.
from publisher in SampleData.Publishers
join book in SampleData.Books
on publisher equals book.Publisher
select new { Publisher=publisher.Name, Book=book.Title };
Left Outer Join
When we want to keep all the elements from the outer sequence, independently of whether there is a matching element in the inner sequence, we need to perform a left outer join.
A left outer join is like an inner inner join, except that all the left-side elements get included at least once, even if they don't match any right side elements.
from publisher in SampleData.Publishers
join book in SampleData.Books
on publisher equals book.Publisher into publisherBooks
from book in publisherBooks.DefaultIfEmpty()
select new {
Publisher = publisher.Name,
Book = book == default(Book) ? "(no books)" : book.Title
};
DefaultEmpty
operator supplies a default element for an empty sequence. DefaultEmpty
uses the default
keyword of generics. It returns null for reference types and zero for numeric value types. For structs, it returns each member of the struct initialized to zero or null depending on whether they are value or reference types.Cross Join
A cross join computes the Cartesian product of all the elements from two sequences. The result is a sequence that contains a combination of each element from the first sequence with eacht element from the second sequence.
from publisher in SampleData.Publishers
from book in SampleData.Books
select new {
Correct = (publisher == book.Publisher)
Publisher = publisher.Name,
Book = book.Title
};