Thursday, March 25, 2010

Request format is unrecognized for URL unexpectedly ending in

Today I want to share with you a new problem which I had faced yesterday.
Problem:
It was about web service related error. I have used Web Method() in my application to fill up a country dropdown. Everything was going well but when I had used this web method it showed me an error like this:

System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCountyList'.

Information:
After googling, I have found the solution.
This error was occured because GET and POST are disabled by default in ASP.NET 2.0 and greater.
Now I would like to share this with you. From msdn I have got some relative information which may help you to get understand clearly.

The .NET-connected Web services support HTTP GET, HTTP POST and SOAP protocols. By default, in .NET Framework 1.0, all three protocols are enabled. By default, in .NET Framework 1.1 or greater, HTTP GET and HTTP POST are both disabled. This is for security reasons.

Applications that use HTTP GET or HTTP POST to invoke a Web service fail when the Web service is upgraded to .NET Framework 1.1 or greater. These applications receive a exception: System.InvalidOperationException: Request format is unrecognized.

Solution:
HTTP GET and HTTP POST may be enabled by editing the Web.config file for the vroot where the Web service resides. The following configuration enables both HTTP GET and HTTP POST:

<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>

For more info pls visits these links:
http://support.microsoft.com/default.aspx?scid=kb;en-us;819267
http://forums.asp.net/t/1459560.aspx
http://aspadvice.com/blogs/ssmith/archive/2007/09/04/FIX-Request-format-is-unrecognized-for-URL-unexpectedly-ending-in.aspx
http://forums.asp.net/t/988377.aspx

Monday, March 22, 2010

How to show Page loading progress with modal background

Problem:
In my recent application development I have faced a strange problem to show modal background with page loading progress. I had tried in different way but not working perfectly. Then I have solved it. I think that there is another efficient way to solved it but now this time it is working for me.

Solution:

In css class:
.divModalBackground
{
filter: alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5;
width:100%;
background-color: #999988;
position: absolute;
top: 0px;
left: 0px;
z-index: 800;
}

In aspx page:
<asp:Panel ID="Panel1" runat="server" Height="900px" Width="100%" CssClass="divModalBackground" Visible="true" >
<asp:Image runat="Server" ID="ImageLoader" CssClass="LoadingProgress" ImageUrl="../../App_Themes/Black/images/ajax-loader.gif" />
</asp:Panel>


In aspx.cs page I put the code like this:
//to show modal popup at page startup
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Panel1.Visible = true;
}

In aspx page place this
// to clear the modal background when page load complete, place this code at the end of your page just before the end of the form tag
<script type="text/javascript" >
function init()
{
var objdiv=document.getElementById('<%=Panel1.ClientID%>')
if(objdiv)
{
objdiv.style.visibility = 'hidden';
}
}

init();
</script>

Thursday, March 4, 2010

Prevent Duplicate record insertion on page refresh in asp.net

Problem:
Today I have faced a new problem(new for me), when I press save button it works fine and then refresh(F5 or Refresh button on browser) the page but this time it is execute the button click event again. For this duplicate data posting on the server.

I try to find out the problem, nothing wrong in my code. Now turn to google and figure out the problem with solution. I have got several solutions. Now I would like to share this solution which solved my problem ......

Solution:

Assume that in Test.aspx page you have a button and a TextBox:
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="110px" OnClick="btnSubmit_Click" />
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>

In Test.aspx.cs..:
public partial class Test : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
btnSubmit.Click += new EventHandler(btnSubmit_Click);base.OnInit(e);
}
protected void Page_Load(object sender, EventArgs e)
{

}
private void Save_Click(object sender, EventArgs e)
{
if (CheckIfDuplicateRequest())

{
return;

}
//Your code to insert the value of the SomeText textbox into the database.
//Set the value of one of the key fields in your web form in session
Session["Refresh"] = TxtName.Text;

}

private Boolean CheckIfDuplicateRequest()
{
if (Session["Refresh"] == null)
{
//Probably submitting the page for the first time
return false;
}
String previousValue = Session["Refresh"].ToString();
if (previousValue != TxtName.Text)
{
//Submitting the page with a different set of values
return false;
}
//Duplicate request.
return true;
}

}

you can get more help from these post:
http://aspalliance.com/687
http://forums.asp.net/p/1296011/3702515.aspx
http://forums.asp.net/p/1190997/2045619.aspx

Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'

Exception: Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'...