.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

RSS feed - Web request fails in 4.0 whereas it works in 3.5

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :.NET Framework
I am trying to get RSS feed from Microsoft blogs thro' web proxy. The Web request fails in .net 4.0 whereas all work fine in .net 3.5... Anything extra to be done in 4.0 while sending the credentials to proxy? Please help me. Code: namespace     testrssfeeder {     /// <summary>     /// Interaction logic for MainWindow.xaml     /// </summary>     public partial class MainWindow : Window {     public MainWindow() { InitializeComponent();     AuthenticationManager.CredentialPolicy = new Proxycredentials (); }     private void Window_Loaded(object sender, RoutedEventArgs e) {     XmlTextReader rssReader;     XmlDocument rssDoc;     Uri httpSite = new Uri("http://www.microsoft.com/communities/rss.aspx?&Title=Blogcasts&CMTYSvcSource=MSCOMBlogPosts&CMTYRawShape=list&Params=%7eCMTYDataSvcParams%5e%7eArg+Name%3d'DateFormat'+Value%3d'MMM+d%2c+yyyy'%2f%5e%7eArg+Name%3d'CategoryGuid'+Value%3d'b286f1d2-c540-405f-abb8-c386d4815f32'%2f%5e%7e%2fCMTYDataSvcParams%5e&NumberOfItems=50");     // Create the request object.     WebRequest wreq = WebRequest.Create(httpSite); wreq.Credentials =   CredentialCa

View Complete Post

More Related Resource Links

Javascript fails in chrome and firefox, works fine in IE



I am customizing Newform.aspx i.e. hiding some fields, making other readonly etc. It works fine in IE but fails miserably in chrome and firefox i.e. readonly are no more readonly, hidden are no more hidden. Here is my code:

<script language="javascript" type="text/javascript">
    function autoFillFields()
       var ctrl = findacontrol("Reference Customer");
    var param = getURLParam('RefFromCust');   
    var properParam = replaceCharacters(param);
    ctrl.value = properParam;
    var ctrl = findacontrol("RefReqOpptyId");
    var param = getURLParam('OpptyId');   
    var properParam = replaceCharacters(param);
    ctrl.value = properParam;

    param = getURLParam('RefFromAE');
    properParam = replaceCharacters(param);
    setPeoplePicker("People Picker", properParam);
    hideFldCtrl("Approval Sta

SharePoint 2010 AD FS 2.0 Integration - login works then fails, looping back to the adfs server

Hello, I setup SharePoint 2010 Claims auth with AD FS 2.0 following this post: http://blogs.technet.com/b/speschka/archive/2010/07/30/configuring-sharepoint-2010-and-adfs-v2-end-to-end.aspx.  I have no access to the ADFS server, but I think they followed the steps as outlined.  If I do an iisreset (or just recycle the app pool of the SharePoint site) I can login successfully using the remote credentials.  Also I can under security in SharePoint search for and find users and roles from the remote ADFS server. If I close my browser, open a new browser and go to the site I am prompted to login again (this is fine).  I do, using the same credentials, and the login fails because I am redirected between the SP and ADFS servers until the ADFS server stops the redirecting.  I have been doing some digging and I found this post: http://blogs.technet.com/b/speschka/archive/2010/08/09/setting-the-login-token-expiration-correctly-for-sharepoint-2010-saml-claims-users.aspx, which describes the situation I have in point # 3 at the bottom.  I have tried setting the token time out as low as 1 second but this hasn't helped. I have also, just to see, tried setting all the other lifetime settings to 1 second - but no luck.  Because the initial login works I think the setup is correct, but something is maintaining some state that is causing the loop

Backup through Central Admin fails; works using stsadm

Hi, I'm trying to schedule automatic backups of my SharePoint 2007 site.  I wrote a .vbs script that does the backup with the following line:   objShell.Run "cmd /c stsadm.exe -o backup -directory """ & BACKUP_DIR & SITE_DIR & """ -backupmethod full -item ""Farm\Windows SharePoint Services Web Application\SharePoint - SharePointSites"" > """ & CURR_DIR & "log.txt""", 0, True   I ran the vbs script from the command line and everything worked fine.  I used the Windows Task schedule to run the script as a scheduled task.  The script ran fine and the backup completed successfully (according to the logs), but now if I go to the Central Admin page and try to do a restore, I get the error:   The backup/restore job failed. In order to rerun the backup/restore the timer job must be deleted from the Timer Job Definitions page. Failure Message: Backup or restore is already running.   The odd thing is I can do another backup or restore using stsadm at the command line and it works fine.  I can also run the scheduled task to do another backup and that works fine too.  I just can't do any backups or restores from Cetnral Admin anymore.   Any suugestions or ideas? Thanks. -Cynthia

Soap request fails


I get the following error when I send a soap request to my service. Any clues what needs to be fixed?

The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
HTTP Error 405 - The HTTP verb used to access this page is not allowed.<br>Internet Information Services (IIS)



Resource Loading Problem (2 UserControls, 1 Load works, 1 Fails. Both UserControls and the Resource


I am having an issue where I have 2 WPF UserControls loading a PNG file from codebehind, the png loads fine in one UserControl, but fails in the other.


This is the top of the codebehind for the UserControl that works...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.ComponentModel;

using ModuleInterface;
using System.Reflection;
using System.Windows.Threading;

first SSL request is failing for some clients, but the second SSL call works


I've got a WinForms client (using ASMX generated proxies) calling an SSL secured WCF service. Without SSL, everything works. With an SSL certificate on the server, some clients fail, but only the 1st web service request. If that same client sends the exact same request a 2nd time, it will work. This happens repeatedly for the same clients.

The client exception will be System.Net.WebException. Unable to connect to the remote server. System.Net.Sockets.SocketException: An invalid argument was supplied

My assumption is the SSL cert is setup incorrectly, but I'm not sure why it only fails for a few clients (although repeatedly), and why it will work the 2nd request? 

EDIT Also, if I turn on Fiddler to try and see the messages across the wire, then the exception does not happen.

Thanks, casey

Clustered SQL 2008 R2 x64, Oracle linked server works on one node, fails on the other


Juicy bits:

- SQL Server 2008 R2 x64

- Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)   Apr  2 2010 15:48:46   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) 

- Active/passive cluster

- Oracle client 11gR1

- "Allow Inprocess" provider option is enabled


I'm stumped.  Our development, QA and UAT environments are all running the same versions of Windows, SQL, and Oracle client.  Linked server between SQL and Oracle works just fine.


Production is clustered.  The linked server works just fine on one node of the cluster, but if we failover to the other node, attempts to use the linked server in any way, OPENQUERY, GUI, etc..., cause the following error:

OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLE" returned message "ORA-12634: Memory allocation failed".

Msg 7303, Level 16, State 1, Line 1

Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "ORACLE".


What am I missing?  I've reinstalled the Oracle client on the defective node, verified that the SQL Server service account has full rights to the Oracle client dir

Request.QueryString works in IE but not Firefox


 I am using a query parameter to pass info from a asp:hyperlink to another webpage.  All works fine in IE but no value comes over in Firefox.  I've attached the relevant code from the start page and the code-behind of the called page. As I mentioned, when using Firefox, the "ChartType" parameter is null when the Page_Load function is called.  Any help would be appreciated.


        <td valign="top">
            <asp:HyperLink id="ViewChart1" runat="server" style="float:right" ImageUrl="Images/ViewNewWindow1.png" onclick="window.showModelessDialog('UnpinnedChartView.aspx?ChartType=1',window,dlgProps); return false;" ToolTip="View Chart in New Window" NavigateUrl="UnpinnedChartView.aspx" />




    protected void Page_Load(object sender, EventArgs e)
        if (!Int32.TryParse(HttpContext.Current.Request.QueryString["ChartType"], out SourceChart)) return;
        HttpContext.Current.Response.Expires = 0;
        HttpContext.Current.Response.AppendHeader("Pragma", "no-cache");  

Trying to instantiate an object of a given type - works if the type has no dependencies, fails if it


In order to instantiate an object of a given type, I'm using the following code


public void LoadAssembly(string pathToAssembly, string assemblyTypeName)
      Console.WriteLine("INFO - Found the Assembly file " + pathToAssembly);
      string fullPath = null;
        fullPath = Path.GetFullPath(pathToAssembly);
        Console.WriteLine("Full path to assembly is " + fullPath);
        Assembly asm = Assembly.LoadFile(fullPath);
        if (asm == null)
          Console.WriteLine("ERROR - Failed to load Assembly: " + fullPath);
        foreach (var item in asm.GetTypes())
          Console.WriteLine("INFO - Found Type: " + item.FullName);
        Type type = asm.GetType(assemblyTypeName);

SQL MERGE syntax works with Win7 SP1 client but fails with earlier platforms

My native C++ client application creates the following SQL  and then uses a Command object to execute it against a SQL Server 2008 database target.  I am finding that the same SQL works fine on Win7 with SP1 or WinServer 2008R2 with SP1 but fails on earlier platforms with Recordset error 80040e14, IDispatch error #3092, description="Incorrect syntax near the keyword 'MERGE'".  
I'm aware of the issues caused by compiling under Win7 SP1 and have reverted to a version of my app which was compiled before SP1 and get the same error.  I'm wondering whether ADO pre-SP1 'understands' the MERGE syntax, or would welcome some advice on what the problem is.  I think my workaround is going to be something like creating a stored procedure and then executing it but the existing way is my preferred one.  Anyway, the SQL is:
MERGE pdata_7_PCYT AS target USING
  qry.[BaseQty], qry.[PromoQty], qry.[PromFlag], qry.[Qty], qry.[GSV], qry.[OffInPCGBP], qry.[OffInvPctGBP], qry.[TtOffInv], qry.[InvValue], qry.[RetrPPCGBP], qry.[RetroPctGBP], qry.[TotRetro], qry.[CSV], qry.[TrmDPPCGBP], qry.[TermsPctGBP], qry.[TermsTot], qry.[NSV], qry.[

Alphabetical order in infopath drop down fails for sharepoint list dataconnection, but it works in p


Hello Experts,

I am using Sharepoint List dataconnection to retrive the drop down in Infopath form & configured several rules to retirve data for other fields based on Id value selected in drop down.

when i modify the list view to display items in alphabetical order, Then i can see the infopath preview mode to display drop down in alphabetical order. But when i deploy as administrator approved XSN in Sharepoint, it doesnt show the alphabetical order which was shown in the preview mode.

How to achieve the alphbetical order in browser enabled forms were it works in preview mode but not when we deploy in sharepoint  ?

Thanks !




SQL Server 2008 CLR Table-Valued function works exactly twice, then fails unless assembly reloaded.


Very simple TVF UDF uses WebRequest and HttpWebReponse, passing the response stream off to custom class that implements IEnumerable. First invocation has a good delay (seen many other posters on this issue), second invocation is lightening fast, then all calls after that produce this error:

Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "tvf_OneMinuteBars":
System.Net.WebException: The operation has timed out
   at System.Net.HttpWebRequest.GetResponse()

Now, I've tried all manner of settings on the webrequest: KeepAlive, Timeout (currently 15 secs), Proxy = null. But I just can't figure it out. What is really a bummer is that I can debug invoke this against a local SQL Server as many times as I like. But if I deploy (in VS) to two different servers, or if I manually copy the assembly to the servers and do the CREATE ASSEMBLY / CREATE FUNCTION manually, it always times out after the second invocation.

Here is the tricky part: the object calling GetResponse calls HttpWebResponse.GetResponseStream(), storing the reference in a property. Then the object reference passed to the constructor of a custom class implementing IEnumerable, which does the right things with the response stream. Super fast, n

Code works on aspx but not ascx


Not sure which category to put this question in, so I will put it in here.

Just to give you an idea of the layout of my solution, I have the main project, along with 2 class libraries, BLL and DAL.  (Business Logic Layer and Data Access Layer)

The BLL refers to the DAL and the main project refers to the BLL.

I had a test website and the code worked fine, but the same code will not work on the real project. The only difference is that in the test project, the code was on an aspx code behind, whereas in the real project, it is an ascx code behind (Web User Control )

The code is:

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString
        Dim recordEntry As New UserRecord(connectionString)
        recordEntry.UserName = "TestName"
        recordEntry.BMI = bMI
        recordEntry.BMR = bMR
        recordEntry.FTM = fTM
        recordEntry.TDEE = tDEE
        recordEntry.TodayDate = dateForToday

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString



Dear gentlemen and ladies of the Microsoft Dynamic Data Team,

Mr. Steve Naughton says (and I hope so) that there might be chances that you read the posts published in this forum: I really hope so.

If that were the case then I am formally requesting to you in providing a "real answer" to my question:

I want to customize a dynamic data page (the details one) so I can have access to the data it has been already gathered from the end user UI (details.aspx) and use it to pass this same data to the following controls/pages that I am going to display next time to the end user.

For instance:

I have a screen with different types of data in it: texts, numbers, dates, check boxes, radio buttons and dropdownlists that has been filled with data by the end user. I want now to reset all fields exept the dropdownlist of which I'd like to keep the previously chosen values(the very same thing you do between dropdownlist of List.aspx ad Details.aspx). Even with FoxPro I could do that because data and controls were available there. It was as simple as setting carrying on to true.


I have found my

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


Unique ID throughout entire request



I am hoping somene here could advise me on a better solution to my present problem.  First a little background information on the application. 

I have a web application using the 3.5 framework.  The structure of this application is as follows: UI -> WebService   -> Business Layer -> DataAccess Layer.   What I want to accomplish is for every request (click on a link or button) have a unique identifer that follows this request through its entire lifecycle.  This unique identifer can be accessible anywhere within this request.  We use Response.Redirects which could easily be changed to Server.Transfers (although I do not want to do that) but  the problem lies with the web service calls.  Currently, a GUID is set in the ApplicationRequest.  This GUID checks for a guid value in the RawURL and if so, assigns this value to a HttpContext Item.  If not, HttpContext.Items gets a new one created.  However, this idea is wrong and will need to be revisisted.  The bigger problem is with the web service calls.  Without changing every web service method signature, and every call for that matter, is there a way of getting this GUID there.  I created a web method in every web service so that each time I instantiate a web service object in the UI, before calling any

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPerm


Good Day all,

Having an issue with an outside user accessing my IIS7 box. I do not have this problem when running the website from my host machine. I found this post: Http://forums.asp.net/t/1371394.aspx. I assure you that this is not a solution because I am not storing any of my files on a network share. 

What do you think my approach should be. 

I already have read rights to IIS user to my BIN folder. 

Thanks for the help. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend