C# - HttpWorkerRequest.GetBytesRead() Always Returns?

Jun 9, 2010

Anyone know why HttpWorkerRequest.GetBytesRead() always returns 0, even during and after a file upload? Would like to use this method to build a progress bar.

View 1 Replies


Similar Messages:

Website Returns 302 Instead Of 200?

Aug 5, 2010

I used a Http Header check tool to check the headers of my webpage and guess what. In every request the response was 302 instead of 200.

domain.con
www.domain.con
http://www.domain.con

So, am i missing something here? I have not placed any redirect in any way.

So where the f#$% my website redirects? Is there a security hole?

UPDATE: While googling found this one

View 4 Replies

C# - WCF Service Returns 400 Bad Request

Mar 18, 2011

I've got this application that works locally and when deployed and using a .mdf SQL Express database file (which I usually use for testing purposes). However, when I change it to work with our SQL Server 2008 the app works but the service doesn't. For example if in my code behind of a page I have a button that adds data to a table such as this it works fine:

public static string connString = @"Data Source=server1;Initial Catalog=Project;Integrated Security=True";
protected void btnAddProj_Click(object sender, EventArgs e)
{
using (var sqlc = new SqlConnection(connString))
{
sqlc.Open();
var cmd = sqlc.CreateCommand();
int intProjectID;
// Add the project info to the database
cmd.CommandText = "INSERT INTO tblProject VALUES(@ProjName,@ProjTeam,@ProjStart,@ProjEnd)";
cmd.Parameters.Add("ProjName", System.Data.SqlDbType.NVarChar).Value = txtProjName.Text;
cmd.Parameters.Add("ProjTeam", System.Data.SqlDbType.Int).Value = ddlTeamSupported.SelectedValue;
cmd.Parameters.Add("ProjStart", System.Data.SqlDbType.NVarChar).Value = txtStartDate.Text;
cmd.Parameters.Add("ProjEnd", System.Data.SqlDbType.NVarChar).Value = txtEndDate.Text;
cmd.ExecuteNonQuery();
}
}

My web.config is setup to use impersonation on that server and all works perfectly well. However, for my service the query doesn't seem to return anything and I get a 400 Bad Request error. The code for the jquery is:

$.ajax({
type: "POST",
async: false,
url: "Services/ProjectService.svc/test",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
console.log(data);
}
});
And for the Service:
[ServiceContract]
public interface IProjectService
{
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Json)]
ArrayList test();
}
public static string connString = @"Data Source=server1;Initial Catalog=Project;Integrated Security=True";
public ArrayList test()
{
var sqlc = new SqlConnection(connString);
sqlc.Open();
var cmd = sqlc.CreateCommand();
cmd.CommandText = "SELECT ProjectID FROM tblProject";
var reader = cmd.ExecuteReader();
ArrayList temparray = new ArrayList();
while (reader.Read())
{
temparray.Add(reader[0]);
}
sqlc.Close();
return temparray;
}

If instead of querying the database I have the service just return static data then it works fine. What could cause my service not to be able to connect to the database when the rest of the code behind for the app works?

View 3 Replies

MVC :: TryUpdateModel Returns True But Does Nothing?

Jan 16, 2011

I have a strongly typed Edit view that expects a viewmodel class. On its post action, I want it to use TryUpdateModel to update the database with the new info. When debugging, TryUpdateModel returns true, but when I look in the database, nothing happened.

This is the controller Action

[Code]....

why this doesn't persist the changes back to the database?

View 2 Replies

C# - SelectionList Always Returns NULL - How To Fix It

Jul 20, 2010

I have a very strange issue where SelectionList always returns NULL when i try check its Selected Item/Value. I Googled a bit and I found out that when i click the submit button, the page is being refreshed and the SelectionList is being data bound again so it will revert back to its original behavior.

Then i tried enclosing the binding code in the Page_Load event in a !IsPostBack but still when i try to access the Selected property it is null and an exception is thrown.

My code goes something like this... (the braces are not matched properly)

static SelectionList[] Symptoms;
static string UserID = "";

cmbSymptoms1,cmbSymptoms2,cmbSymptoms3 and cmbSymptoms4 are SelectionLists. I took them in to an array of SelectionList and then set the properties.

I had to make them static or else when i click the button to update, they will not retain their values.

protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
//System.Diagnostics.Debug.WriteLine("Not IsPostBack");
if (Request.QueryString["id"] != null && Request.QueryString.ToString() != "")
{
//System.Diagnostics.Debug.WriteLine("id query string is not null :- " + Request.QueryString["id"]);
myclass = new Class1();...........

View 1 Replies

Any Webservice That Returns JSON?

May 11, 2010

Does anyone know of free webservice that returns a list in the form of JSON? I have searched many webservice sites but they all return xml. Geonames.org is not required.

View 3 Replies

Array Returns 0 Instead Of Assigned Value?

Aug 18, 2010

I assigned a int value to to one of the cells in an array and then output that value to a label. The label correctly displays that value however when I try to get that value later in a different method the cell returns a 0. I think that the problem is that I shouldn't of made the array on the outside of a method; I checked the code that deals with the array about 3 times and it all seems fine. how I should create, get, and set this array. I was setting the value of the cell like this

arrayForXps[0,1] =Convert.ToInt32(ddl_att_desLvl.SelectedValue); //This value is never zero.

I was getting the value like this Label.Text = Convert.ToString(arrayForXps[0,1]);

[Code]....

View 1 Replies

SQL Server :: SCOPE_IDENTITY() Always Returns 0?

Mar 3, 2011

I am trying to return the identity value of a inserted record for the first time in ASP.NET but it always returns 0, I can see in the database that a record is being inserted and the identity value is not 0.

Stored Proc:

[Code]....

Code Behind:

[Code]....

View 8 Replies

C# - 'Contains' Method Returns False?

Jan 16, 2011

I've an EntityCollection< T > which contains an element but the Contains method returns false.

I've overriden T's 'Equals' method but the 'Contains' method does not call it (while it's said so in documentation).

When I do foreach (T x in coll), x.Equals(element) returns true.

code:

contains(object entCol, object val)
{
var coll = (ICollection<GraphicSockets>)entCol;
var socket = val as GraphicSockets;
foreach (GraphicSockets sock in coll)
socket.Equals(sock); //true for first element, GraphicSocket's Equals function called
coll.Contains(socket);//false, Equals function not called}

the code i'd actually like to use is

private static bool contains(object entCol, object val)
{
Type entColType = typeof(EntityCollection<>).MakeGenericType(val.GetType());
MethodInfo contains = entColType.GetMethod("Contains");
return (bool)contains.Invoke(entCol, new object[] { val });
}

this worked once but stopped when i started using wcf, i wonder how this contains method works.....

View 2 Replies

C# - Telerik RadAjaxPanel Returns 404?

Oct 15, 2010

I'm trying to do a RadAjaxPanel ajaxRequest (invoked on the client) to call the server event-handler. I'm getting a 404. I do have a server-side AjaxRequest handler defined but it never gets call because of something with the request. What do I have to do to figure this out?

.NET 4.0, IIS 7.5, latest telerik.

View 1 Replies

Vb.net Function Returns Either String Or Nothing?

May 25, 2010

I'm tring to create a vb.net 3.5 function that can return either a string or nothing.

Public
Shared
Function MakeLookupField(ByVal pasString
As
String)

[Code]....

What can I set the return variable to return either a string or null value

View 7 Replies

MVC :: Typing A URL Some How Returns /Home?

Mar 5, 2011

I have a weird problem with my MVC application.In my _Layout.cshtml file I have created 3 menu links and each points to a location. On my personal PC clicking each link will browse to the specifc page without any issues. However, when I deployed my app to a hosting website. The first 2 links work fine but the 3rd one returns me to ~/Home

Using IE developer tools here is the network capture:

Request: GET /myapp/mylink HTTP/1.1

Accept: imaged/jped etc..

Refer: /myapp/home

The response is as follow:

Response: HTTP/1.1 302 Found

Location: /myapp/home

I am not really sure why am I getting a HTTP 302 and causing a redirect to /myapp/home.

View 1 Replies

Asp.net - Dataset Column Always Returns -1?

Aug 20, 2010

I have a SQL stored proc that returns a dataset to ASP.NET v3.5 dataset. One of the columns in the dataset is called Attend and is a nullable bit column in the SQL table. The SELECT for that column is this:

CASE WHEN Attend IS NULL THEN -1 ELSE Attend END AS Attend

When I execute the SP in Query Analyzer the row values are returned as they should be - the value for Attend is -1 is some rows, 0 in others, and 1 in others. However, when I debug the C# code and examine the dataset, the Attend column always contains -1.

If I SELECT any other columns or constant values for Attend the results are always correct. It is only the above SELECT of the bit field that is behaving strangely. I suspect it has something to do with the type being bit that is causing this. So to test this I instead selected "CONVERT(int, Attend)" but the behavior is the same.

I have tried using ExecuteDataset to retrieve the data and I have also created a .NET Dataset schema with TableAdapter and DataTable.

View 2 Replies

MVC :: Route Returns A 404 Error Sometimes?

Dec 19, 2010

when the server reboots, one route sometimes returns a 404 until the site is manually restarted. why is that? using mvc 3 rc1 and razor views.

View 16 Replies

VS 2010 - Returns A Comma Instead Of ID

Aug 5, 2014

My problem is that all of a sudden the __EVENTTARGET isn't working. It returns a comma for some controls (that arent given that ID of coure). At first I didn't have the energy to investigate this, I just made sure the comma was handled. But that was before I needed another control (asp:button) to behave in a certain way. Now the button returns a comma as ID, which triggers an event that I don't want for the button_click.

View 5 Replies

C# - Variable Returns To Its Default Value (zero) In Other Scopes?

Sep 22, 2010

Can I assign a value to a variable (int) and never lose this value inside any scope? the problem is I am assigning the value to the variable in some scopes but the variable returns to its default value (zero) in other scopes..

protected void Button_AddNewCourse_Click(object sender, EventArgs e)
{
ID = 10;
}

so when I am trying to use ID in other functions it falls back to zero

protected void AnotherFunction(object sender, EventArgs e)
{
// Variable ID here is zero
}

View 3 Replies

MVC :: Static Content Returns A 500 Error?

Nov 16, 2010

I think I might be missing something obvious but I'm not sure. The other day I was trying to run throught the windows live ID domain verification process on my asp.net mvc site. Part of the process requires you to download a text file and put it in the root of your site which your domain points to. When I would click the verify button in the windows live app verification process it would fail. In a browser, I could hit the request the text file and get a 200, which puzzle me. I then used this site http://www.internetofficer.com/seo-tool/redirect-check/ to check for any redirection issues. Suprisingly when I enter in the url to check, in my case http://www.whatitcoststobeme.com/741KXPjf42zgZRnV6O1LsO92.txt, it returns a 500 error. I ran this same test against a non-MVC site and the verificaton process passed plus the redirection checker return a 200 ("direct link" on their site). The environment this was tested in was IIS7.

why this is happening with static content on a ASP.NET MVC site? I want to say it's something to do with the url routing handlers.

View 6 Replies

C# - The IndexOf() Method Returns -1 All The Time

Aug 26, 2010

i have two data tables with the same structure

the first one has one row of the second one

the second one has set of rows

what i want is to get the row which comes next to the row of the first data table in the second data table.

the first data table his name is :: temp

the second data table his name is :: dt

i do the following:

DataTable temp = new DataTable();
temp = dt.Clone();
DataColumn[] keyColumn = new DataColumn[1];
keyColumn[0] = temp.Columns["photoId"];
temp.PrimaryKey = keyColumn;
temp = (DataTable)(Session["currentImage"]);
DataRow[] drr = new DataRow[1];
index = dt.Rows.IndexOf(temp.Rows[0]);

but the index always comes with one value = -1

although the temp.rows[0] its contents changed all the time

when i write dt.Rows.IndexOf(dt.Rows[1]) for examble i get 1

but this is not what i want to do ,, what i want to do exactly is to get the datarow next to the datarow of the first dataTable in the second dataTable

View 2 Replies

Mvc Json - Color Always Returns Null

May 22, 2010

I am working on a mvc project, and having problem with json. i have created a demo project with list of colors

public JsonResult GetResult()
{
List<string> strList = new List<string>();
strList.Add("white");
strList.Add("blue");
strList.Add("black");
strList.Add("red");
strList.Add("orange");
strList.Add("green");
return this.Json(strList);
}
i am able to get these on my page, but when i try to delete one color, that is when i send the following using jquery
function deleteItem(item) {
$.ajax({
type: "POST",
url: "/Home/Delete/white",
data: "{}",
contentType: "application/json; charset=utf-8",
success: ajaxCallSucceed,
dataType: "json",
failure: ajaxCallFailed
});
}

the controler action public JsonResult Delete(string Color) {} Color always returns null, even if i have specified "/Home/Delete/white" in the url. i know i am doing something wrong or missing something, but not able to find out what.

View 4 Replies

ListBox Always Returns First Value (-1 Selected Index)

Feb 19, 2011

I have two ASP.NET ListBoxex in a usercontrol.

databinding event fires once. i am sure and i did trace.

but listbox always returns first value !

it is strange for me.

and i don't know how to fix it.

[code]....

View 1 Replies

ADO.NET :: SP From Linq Returns Empty Or Null Value

Feb 15, 2011

I have a class library which has my LINQ doc in it. I added a stored procedure and I get the following in my .dbml.layout :

[Code]....

I include a reference to the dll of the class library to my web project and I get an error about value being returned as int where I am trying to put contents into a datalist or similar.

Code in class that calls this SP :

[Code]....

So I switched code to the following in my dbml.layout document :

[Function(Name="dbo.sp_newsSearch")]public IEnumerable<news_search_result> sp_newsSearch([Parameter(DbType="VarChar(200)")] string searchVal){IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), searchVal);return ((IEnumerable<news_search_result>)(result.ReturnValue));}

And included the following in an external file news_search_result.cs

[Code]....

But now I just get nothing returned. Is this wrong way of calling a SP via LINQ? or have I just put the wrong return type on my LINQ class?

View 2 Replies

C# - Can Get WCF FaultException When Server Returns An HTTP 401

Jan 11, 2010

I have a WCF based test harness client for a set of web services. The test client allows me to see raw requests and responses going to and from the services. A Message Inspector endpoint behavior is used to "pick off" the raw requests and response messages and save them for later display in the UI.

This works great, except for the use case where invalid credentials are passed. The server returns an HTTP 401 along with a SOAP fault containing details of what happened. This hurts me in a couple ways:

On the client this shows up as a MessageSecurityException not a FaultException, so I can't get the details from the fault. This exception appears to prevent the AfterReceiveReply event handler on my message inspector from firing, so I have no access to the raw response.

Is there any way I can handle this case so that the SOAP fault comes through as a FaultException and allow my message inspector to handle responses regardless of the HTTP status code that is returned?

View 1 Replies

Validation - Recaptcha Asp.net Always Returns Invalid?

Mar 30, 2010

The reCaptcha example for ASP.NET does not seem to work. I followed the instructions but it always returns false, "The verification words are incorrect.". The entries are good. I'm using localhost as the site but am not getting any public/private key errors which I did get when adding a bad key (as a test).I've seen this error reported a lot but no good answers. Some suggest to call the validate on the control before checking to see if it is valid but this did not work for me.

View 2 Replies

MVC :: RegularExpressionAttribute Validator Always Returns False?

Nov 17, 2010

I'm using a model which receives some input from a form and has some validation logic attached via attributes. In one case I'm validating personal names, which should include only letters, apostrophes, spaces and dashes, and be no more than 50 chars long. So I have a model property like:

[Code]....

Everything works fine BUT the RegularExpression attribute: if I add it, I always get a validation error, even when what I type in my form is a valid name (e.g. "Foo"). No matter how I modify the regular expression or what I type, I always get an invalid name error.

(For some reason, I cannot see the regex posted correctly here: it is just ^ followed by the Unicode Letter class and []+ including a Unicode letter class, apostrophe, whitespace and dash, ended by dollar: i.e. start of string - any letter - any of the following: letter, apostrophe, whitespace, dash, 1 or more times; end of string).

What I'm doing wrong here?

View 8 Replies

Web Forms :: Carriage Returns In A TableCell?

Mar 23, 2010

I have a tablecell where I import the text from a SQL database and this all works well, except that the carriage returns are not being displayed in the text.

I have done some googling and although I do not get any error messages, the carriage returns are not appearing in my table cell.

Here is the code:

[Code]....

I have also tried Environment.NewLine, etc. but all to no avail.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved