I have been working with Microsoft Entity Framework for more than a year now. It's cool! Recently I got a chance to do a session to my office mates on "Getting started with Microsoft Entity Framework" at the weekly office tech talk presentations. I have uploaded them on slide-share. If it gets too much time too load visit either http://www.slideshare.net/slideshow/embed_code/12726298 or http://www.slideshare.net/lushanthan/getting-started-with-entity-framework
Saturday, April 28, 2012
Friday, October 28, 2011
Cross domain policy for silverlight to access a WCF Service
Today, I'm posting about an issue which I faced when making a WCF Service to be accessible across different domains. And this was for a silver-light chat application. The chat application didn't work for me, and it threw me the below error when I debugged.
"An error occurred while trying to make a request to URI http://SampleSite/Chat Service.svc. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details."
"To enable a Silverlight control to access a service in another domain, the service must explicitly opt-in to allow cross-domain access. By opting-in, a service states that the operations it exposes can safely be invoked by a Silverlight control, without potentially damaging consequences to the data that the service stores.
Silverlight 4 supports two different mechanisms for services to opt-in to cross-domain access:
- Place a clientaccesspolicy.xml file at the root of the domain where the service is hosted to configure the service to allow cross-domain access.
- Place a valid crossdomain.xml file at the root of the domain where the service is hosted. The file must mark the entire domain public. Silverlight supports a subset of the crossdomain.xml schema. "
This is even clear when you use the nikhilk's Web development helper with ie( can view request, response details) and check out the request [2] (check video) . It searches for those two files.
Here are the two files that are needed.
clientaccesspolicy.xml
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
Save both these files to the root of the domain where the service is hosted. If, for example, the service is hosted in http://fabrikam.com, then the file must be located at http://fabrikam.com/crossdomain.xml. Thanks to MSDN!
References
[1] http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx
[2]http://www.silverlight.net/learn/data-networking/introduction-to-data-and-networking/how-to-use-cross-domain-policy-files-with-silverlight
Check out the above video [2] by Tim Heuer . It was really helpful!!!
Labels:
cross domain,
silverlight,
wcf
Location:
Colombo, Sri Lanka
Intellisense not working on MVC
Recently I had an opportunity to work on an Microsoft MVC 2 project. For me, the intellisense didn't work on the MVC web pages.
I also got the below run time error because of using the log4net dll. However, the reference to the dll was correct.
"ASP.NET runtime error: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))".
Solution:
The Solution is to clear the "C:\Windows\Microsoft.NET\ Framework\v4.0.30319\Temporary ASP.NET Files\" files. It works now! Cheers!!!
I also got the below run time error because of using the log4net dll. However, the reference to the dll was correct.
"ASP.NET runtime error: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))".
Solution:
The Solution is to clear the "C:\Windows\Microsoft.NET\
Labels:
intellisense,
MVC,
VS2010
Location:
Colombo, Sri Lanka
Monday, January 17, 2011
onmouseover="JavaScript:this.style.cursor='hand'" not working in Firefox
hi all, this is a small CSS issue which I came across today, and was able to fix it out. This code below works wells with IE, but not with Firefox on mouse-over of an image/ div .
The solution is to replace "hand" with "pointer".
cause, The standard is "pointer", not "hand". "hand" is for IE 4/5.
Regards,
Lushanthan. S
< div >
< asp:Image ID="Image1" runat="server" ImageUrl="~/Images/chat.png" onmouseover="JavaScript:this.style.cursor='hand' " / >
< /div >
The solution is to replace "hand" with "pointer".
< div >
< asp:Image ID="Image1" runat="server" ImageUrl="~/Images/chat.png" onmouseover="JavaScript:this.style.cursor='pointer' " / >
< /div >
Regards,
Lushanthan. S
Sunday, October 31, 2010
More Stored Procedures (Add and Update)
Given below is a stored procedure for adding data into a table.
ex3-
create procedure MyStoredProcedure3
(
@para1 varchar(100),
@para2 int,
@para3 varchar(500)
)
insert into [Table1]
values (@para1,@para2,@para3)
note here that the parameters you input (@para 1,2 and 3) will set stored in the 1st, 2nd and 3rd columns respectively. And here you need to specify data for all the columns in the table. But, if you want to make it specific you can try the below example.
create procedure MyStoredProcedure3
(
@para1 varchar(100),
@para2 int,
@para3 varchar(500)
)
insert into [Table1]([column2],[column3],[column4]
values (@para1,@para2,@para3)
Here para1, 2 and 3 will get stored in the column 1, 2 and 3 of the table. The other columns in the table should allow nullable values, except for the primary key column which in this case can be auto-incremented. Also note that when you input data to an auto-incremented primary key column it will throw an exception.
Given below is a stored procedure for updating a row in a table.
ex4-
create procedure MyStoredProcedure4
(
@para1 int,
@para2 varchar(100),
@para3 varchar(500)
)
update [Table1]
set [column2]=@para2,[column3]=@para3
where [column1]=@para1
Good Day! See you next time with some more examples..
ex3-
create procedure MyStoredProcedure3
(
@para1 varchar(100),
@para2 int,
@para3 varchar(500)
)
insert into [Table1]
values (@para1,@para2,@para3)
note here that the parameters you input (@para 1,2 and 3) will set stored in the 1st, 2nd and 3rd columns respectively. And here you need to specify data for all the columns in the table. But, if you want to make it specific you can try the below example.
create procedure MyStoredProcedure3
(
@para1 varchar(100),
@para2 int,
@para3 varchar(500)
)
insert into [Table1]([column2],[column3],[column4]
values (@para1,@para2,@para3)
Here para1, 2 and 3 will get stored in the column 1, 2 and 3 of the table. The other columns in the table should allow nullable values, except for the primary key column which in this case can be auto-incremented. Also note that when you input data to an auto-incremented primary key column it will throw an exception.
Given below is a stored procedure for updating a row in a table.
ex4-
create procedure MyStoredProcedure4
(
@para1 int,
@para2 varchar(100),
@para3 varchar(500)
)
update [Table1]
set [column2]=@para2,[column3]=@para3
where [column1]=@para1
Good Day! See you next time with some more examples..
Saturday, April 25, 2009
Web Development and Design - Begining with SQL
Creating Stored Procedures- Basics
For this, you should have the basic knowledge on creating queries in SQL(visit http://www.w3schools.com/sql/default.asp).
Wat is really a stored procedure?
It is more like making the sql statements programmable! These stored procedures are stored in the database. It can take parameters and return what you want. Then you can easily call this procedure from a remote application, and get your result. It begins with the keyword create procedure
ex1-
Here is an example for the select query.
(If you want the whole records in the table)
create procedure MyStoredProcedure1
as
select * from [TableName]
ex2-
Here is an example for the select query with input parameters. (If you want a particular row / set of row- using the where condition)
Here, the input parameter will be given by the user which is dynamic.But, when using a SQL statement we write the where clause like,
select * from [TableName] where [columnName] = 23. The value 23 should get changed according to what user inputs. For that we can write a procedure like ,
create procedure MyStoredProcedure2
(
/*input parameters with their type*/
@para1 varchar(50)
)
as
select * from [TableName] where [columnName] = @para1
Here the type of the parameter given should be the type of its corresponding [columnName].
In the next lesson we will look into more examples on stored procedures.
Good Day.
Subscribe to:
Posts (Atom)
