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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how can i return 401 error from a method return ActionResult?

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

how can i return   401 error from a method return ActionResult?

View Complete Post

More Related Resource Links

linq and max, if return null return error


hi there
i have this query :

var result2 = (from TH in DB.Threshold
                          where TH.ProductSKUID == int.Parse(HID_ProductSKUID.Value)
                          select TH.ThresholdID).Max();

the problem is that if this query does not find any items, return null, so thow exception
how can i do to return 0??

More than one records return error

Hi Below is my query used in procedure. This query can return no records or more than one records. If this is the case then I wanted to return error message. How to do this? Select Band, SimpleBand into <complexband>, <simpleband> from HHSRS_HazardBand where lowerbound <= <hazardscore> and upperbound > <hazardscore>  

ASP.net Web Site Administration Tool. An error was encountered. Please return to the previous page a

I have just installed Visual Studio 2010 trial. Previously I have been using Visual Studio Web Developer 2010 Express. Now every time I try to invoke the ASP.net Cofiguration tool either via the icon or through the Project File Menu item, I get the error message "An error was encountered. Please return to the previous page and try again." I am trying to develop a bog standard Silverlight Business Application. There are no other diagnostics. Is there anywhere I can look for more clues or anything else to do to alleviate the problem? or is this something peculiar to the trial version I am using?   I also think it might have something to do with the fact that I have created this Silverlight Business App on a directory on my D: drive and not the normal, default c: drive path and maybe the web sit admin tool is looking somewhere else. Could this have something to do with it? If so what is my remedy?   Help please.....

Error: "Select statements included within a function cannot return data to a client"

hi all, Not sure if there is an easier way to do this but this is my first ever Function I created so far. I am getting the error: "Select statements included within a function cannot return data to a client" All I am trying to do is ...if the date is NOT passed then apply NULL as the default value and run the SELECT statement. If the date IS NOT null then run a different SELECT statement. CREATE FUNCTION [SchemaTest].[fn_Test] ( @instance as uniqueidentifier ,@date as datetime = null ) RETURNS varchar(8000) AS BEGIN If (@date is null) --@date = null ?? Begin Select * From Uds.RealtimeLogging Where instanceID = @instance End Else Begin Select * From Uds.RealtimeLogging Where instanceID = @instance and [timeStamp] > @date End Return @stepIds END Thank you!JCD

Bind a ListView to a return value from a method

I have a ListView in my View that I would like to bind to the return value of a method on my ViewModel. View:   <ListView DataContext={???}" />   ViewModel:   public void GetParameters(string foo) { return myObj.FindParameters(foo); }   My question is, what would the binding syntax look like on the View's ListView to call GetParameters, and pass in a parameter (argument)?  

Getting VP.NET code to respond to SQL Return values and Error Codes


I have SQL stored procedures that will return values depending on the outcome of its execution. I have the following code at the end of each of my Stored Procedures:

RETURN @siReturnValue

It would be great to be able to use this Return value after running the Stored Procedures from my VB.NET code. I have included an example of how I am running SQL Stored Procedures below:

    Public Function SearchKeyword(ByVal SearchString As String) As Data.DataTable
        Dim AerialConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("aerialConnectionString").ConnectionString)
        Dim MediaArchive As New Data.DataTable
        Dim reader As SqlDataReader
            Dim SelectMediaArchiveCommand = New SqlCommand("EXEC spSearch @keywords", AerialConnection)
            SelectMediaArchiveCommand.Parameters.AddWithValue("keywords", SearchString)
            reader = SelectMediaArchiveCommand.ExecuteReader()
        Catch e As Exception
        End Try
        Return MediaArchive
    End Function

How can I code this to respond to different Return values, or even error cod

Browse /ReportServer return 401.3 error after joined domain



Hi all,

After my server joining a domain, when I try to browse the ReportServer by using a local user account call 'ReportViewer' with "browse" role. I got the follow error:

Server Error in '/ReportServer' Application.

Access is denied.

Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control List). Ask the Web server's administrator to give you access to 'c:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Rporting Services\ReportServer\Reserved.RportServer'.

My 'ReportViewer' user which belong Users group used to works fine before my machine join the domain. And I check both follow folders and the Users group do have read and execute permission.

  • C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportManager
  • C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer

Environment Information:

  • SQL Server 2008 (64 bit) along with SSRS and SSIS is installed on a 64 bit machine Running Windows Server 2003 R2 Standard,

People Picker fails to search or resolve and return an error message.



I got an error while trying to access the people picker from some specific locations. I'm experiencing those problems ONLY in the cental administration and also there, just on a few places. For example if I try to change the authorization settings of any service application there is a different people picker pop up than, for example, if I want to change the admins of any service application. Any other people picker window outside the central administration works for me.

So it seems to me, that there are two different types of people picker windows. The one which is not working for me also appears in the metadata service application which is the reason I can't use this service as I'm not able to define an owner of a keyset.

In the error log I found the following message: "Ausnahme im Forderungsanbieter 'Alle Benutzer' beim Aufruf von 'SPClaimProvider.FillHierarchy()': Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt." It basically says: An exception occurred in 'all users' claim provider when calling 'SPClaimProvider.FillHierarchy()': The object reference was not set on a object instance. This is event-id 8307 which you can find here: http://technet.microsoft.com/en-us/library/ff535778.aspx

WCF async call return a 10054 error: "An existing connection was forcibly closed by the remote host"



I have a WCF consumed by a Windows Mobile 5.0 or above application with .NET Compact Framework 2.0 SP2 and C#.

When the application consume a asynchronous "method" it throws that message. This is also the stackTrace of inner exception:

at System.Net.Sockets.Socket.ReceiveNoCheck()

Can a method return multiple types?



I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList.

On the top of my head, I could merge them and return an Object, and then get the information I need.

Is there a way though to return multiple types in the method's signature?

What's the proper way to implement this?


OCIEnvCreate failed with return code -1 but error message text was not available.



We have a requirement to connect to oracle from ASP.NET and we installed ODAC(ODAC1110621) components  on the server but still we are getting the following error while opening the connection. Please find the details below:-

OCIEnvCreate failed with return code -1 but error message text was not available.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: OCIEnvCreate failed with return code -1 but error message text was not available.

Source Error:

Line 16:     {
Line 17:         OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["HRDBA"].ConnectionString);
Line 18:         con.Open();
Line 19:         Label1.Text = con.State.ToString();
Line 20:         con.Close();

Source File: \\hs003fs01-02.homebase.com\wfmp\Webpage1.aspx.cs    Line: 18

Stack Trace:

Revised Question XML Value Method Return Multiple Rows


Question earlier asked and answered to run query to collect sql data from xml schema

was able to collect the scheme from node but query did not return data but xml string


I ran this query

select x.col.value ('




cross apply



XML Value Method to return multiple records


I am new in XML SQl i have created a schema with namespace in SQL 2005; I can return single records with the following query using table and column name; however, i do not understand how to return multiple (nodes) records from xml segments where there are multiple (same) elements.

Here is the query which works with one record, when trying to declare the Namespace to use nodes get error

The schema is an HIPAA 837 schema with multiple elements ; Table name = PATIENTTRAC_SUBMISSION_HISTORY; xml field = PATIENTTRAC_EDI_SUBMISSION




Error 504 - ReadResponse() failed: The server did not return a response for this request.


When I call this method from my wcf serivce :

        public override Restaurant[] GetAll()
            return (from c in GetContext().Restaurants orderby c.Name select c).ToArray();

I get following inner exception :

 {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}



Error on getting return value from Oracle procedure in SSIS package

In my case, I want to execute a stored procedure in Oracle database using SSIS package and if there has error in Oracle, I want to get the error message from Oracle and pass it to SSIS to log the error.

I can execute the stored procedure through SSIS successfully, but the problem is I cannot get the error message using OUT parameter of procedure in Oracle, the following part is what I have done to test whether SSIS can fulfill my requirement:

1. Oracle client installed, use Microsoft OLE DB Provider for Oracle, Test Connection to Oracle succeeded.

2. The stored procedure created in Oracle database:
    create or replace p1(in1 varchar2, out1 OUT varchar2) as begin
        out1 := 'nice';

3. In the SSIS package, I add a "Execute SQL Task" component:

Variable defined = User::output (String datatype)
ResultSet = Single Row
SQLSourceType = Direct Input
SQLStatement =

        in1 varchar2(10);
        out1 varchar2(10);
        in1 := 'wow';
        out1 := '1a2';

Web Service Return Custom Error Code


I'm trying to write a Web Service that will return several different error codes so the client can handle each error code individually (e.g. err=600 call funcA, err=700 call funcB, etc..).

My code below always returns "500" for the _statusCode (or get_statusCode). Am I doing this wrong? How do I get a Web Service to return custom error codes to the client (javascript)? Any info appreciated. Thanks.


If IsNothing(Membership.GetUser(UserName.ToString.Trim)) Then

objReturnValue = New UserInfo(UserName.ToString.Trim, False)


objReturnValue = Nothing

Err.Raise(vbObjectError + 601, "UserExists", UserName)

End If

Webmatrix.Data.Database.Query() method return type


I'm using the Webmatrix.Data.Database.Query method to return a result set in the following form

var myResult = db.Query("Select * from mytable");

How do you cast myResult to get the count of records returned? I'd like to do something like


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