MVC :: Null Action Id Returns System.NullReferenceException?

Oct 26, 2010

This is what I'm trying to run:

[Code]....

When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:Server Error in '/' Application.Object reference not set to an instance of an object.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.NullReferenceException: Object reference not set to an instance of an object.

View 3 Replies


Similar Messages:

ServerControl Randomly Null / System.NullReferenceException?

Apr 8, 2010

I got a master page with a server control in it. Randomly the server control is inaccessible from codebehind. This doesn't happen on a specific action (eg a Button click or so). Currently I have no clue what this could be. I don't think it's output caching since this is not explcitly activated and the error happens far to seldom for that. But I'm going to disable caching in the master page explicitly with next deployment.

The control is defined in markup. The accompaning codebehind is:

PGFMainNavi.HasAccessToFunction = HasAccessToNaviItem;
// HasAccessToNavi is a local function

Exception is:

System.NullReferenceException: Object reference not set to an instance of an object

View 1 Replies

System.Web.Security.FormsAuthentication.Encrypt Returns Null?

Apr 21, 2010

I'm trying to encrypt some userData to create my own custom IPrincipal and IIdentity objects using Forms authentication - I've serialized an object representing my logged in user to Json and created my FormsAuthentication ticket like so:

string user_item = GetJsonOfLoggedinUser();/*get JSON representation of my logged in user*/

System.Web.Security.FormsAuthenticationTicket ticket =
new System.Web.Security.FormsAuthenticationTicket(1,
WAM.Utilities.SessionHelper.LoggedInEmployee.F_NAME + " "
+ WAM.Utilities.SessionHelper.LoggedInEmployee.L_NAME,
DateTime.Now, DateTime.Now.AddMinutes(30), false, user_item);
string encrypted_ticket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
HttpCookie auth_cookie =
new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, encrypted_ticket);
Response.Cookies.Add(auth_cookie);

However, the string encrypted_ticket is always null. Is there a limit on the length of the user_item string?

View 1 Replies

Test That A Controller Action Simply Returns A Link To Another Action?

Apr 29, 2010

Lets say I have a simple controller for ASP.NET MVC I want to test. I want to test that a controller action (Foo, in this case) simply returns a link to another action (Bar, in this case).How would you test TestController.Foo? (either the first or second link)

My implementation has the same link twice. One passes the url throw ViewData[]. This seems more testable to me, as I can check the ViewData collection returned from Foo(). Even this way though, I don't know how to validate the url itself without making dependencies on routing.The controller:

public class TestController : Controller
{
public ActionResult Foo()[code].....

View 1 Replies

VS 2008 Get The Following Error: System.NullReferenceException / How To Solve It

Jul 28, 2010

I am having some issues accessing a literal in a usercontrol.

I get the following error: System.NullReferenceException: Object reference not set to an instance of an object. at page.sbPageLoad(String sTypeCD, Int32 iCategoryID, String SortExpression)

Does the following code below look right?

Here is my usercontrol named: topbanner.ascx:

Code:

[code]....

View 3 Replies

VS 2008 DataRow Error System.NullReferenceException?

Jul 26, 2010

When I click on my btnMissionary_Click which is suppose to add a datatable row I am getting the following error:

System.NullReferenceException: Object reference not set to an instance of an object. If I add a entry right away it seems to work fine.

Here is my form
HTML Code:
<div id="container">
[code].....

View 6 Replies

Web Forms :: Chart, RenderControl, & System.NullReferenceException?

Feb 23, 2010

I need to get the html of a chart control built at runtime. When I call .RenderControl, I get System.NullReferenceException. What could the problem be? Is there another way to go about this (saving as image)? Below is my code.

[Code]....

View 2 Replies

Security :: FormsAuthentication.SignOut() Results In System.NullReferenceException?

Aug 26, 2010

I am getting a "System.NullReferenceException" when I call

View 3 Replies

Web Forms :: Exception Details In System NullReferenceException - Object Reference Not Set

Mar 16, 2011

i hav e1 drop down list where is is to filter shif code , ddl text field contaoins shift desc and value contains shift code.

when i select particular shift description it has to show all the 7 days shift description on text boxes iam using informix database

i have 1 dropdownlist which contains shiftcode & shift decription. where shift code is datavalue filed and desc is dat text field. ddl is conected to sql datasource.

i am getting this error:

Object reference not set to an instance of an object.


[Code]....

Source File: C:srcAicWappPersonnelShiftTime.aspx.vb Line: 33 Stack Trace:

[Code]....

here is my code..

[code]....

[Code]....

View 6 Replies

Web Forms :: Exception Details - System.NullReferenceException / Object Reference Not Set To An Instance

Sep 23, 2010

i have a Problem, i made a ASP.NET Page with VS2010 and now i want to run it on a iis6 (windows server 2003) and i get the message:

[Code]....

The Source Code of the File is:

[Code]....

Why do this error only come on IIS6?

View 4 Replies

DataSource Controls :: Receiving Error - System.NullReferenceException - Object Reference Not Set

Dec 25, 2010

I receive the following error in the code below: System.NullReferenceException: Object reference not set to an instance of an object. When I am logged into the page I do not receive the error. My Code:

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub SqlDataSource4_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Handles SqlDataSource4.Selecting
Dim MemUser As MembershipUser
MemUser = Membership.GetUser()
UserID.Text = MemUser.ProviderUserKey.ToString()
e.Command.Parameters("@UserId").Value = MemUser.ProviderUserKey.ToString()
End Sub
End Class

I read the following online: You are trying to use a reference variable who's value is Nothing/null. When the value is Nothing/null for the reference variable, that means it is not actually holding a reference to an instance of any object that exists on the heap. You either never assigned something to the variable, never created an instance of the value assigned to the variable, or you set the variable equal to Nothing/null manually, or you called a function that set the variableto Nothing/null for you. The following is the Arthur's code example and his suggested fix which I am sure is right:

Private Sub TestString()
Dim a As String
If a.Length = 0 Then
Console.Write("Yes")
End If
End Sub

View 3 Replies

Testing Controller Action Which Returns RedirectToRouteResult?

May 19, 2010

I have an action in my controller:

RedirectToRouteResult Create(UserDTO UserDTO)

Which at some point decides with which HTML to respond after a post request by redirecting to an action:

return ModelState.IsValid ? RedirectToAction("ThanksCreate") : RedirectToAction("Register");

In my unit tests I would like to get hold of the 'views' modelstate somehow like this:

var modelState = result.ViewData.ModelState;
Assert.IsFalse( modelState.IsValid );

where 'result' (ViewResult) is the result of the action 'Create' depending on the submitted DTO. My dilemma is that my action 'returns' a RedirectToRouteResult which I thought is quite nice but it might not be testable or is it?

How could I get hold of the ModelState in my scenario?

View 1 Replies

MVC :: Action That Returns Viewresults For Ajax Client To Consume?

Dec 10, 2010

I have an action that will return partial view result if no error is found in the request , but when an error is found , how do I pass the error information back to client ?

Some error info now is in TempData["message"] , but some are model validation messages . The web client is using jQuery to make the ajax request (with $.ajax( ) call ) .

How does the jquery client distinguish between sucess or failure , and then acts appropriately to update a DIV that display TempData["message"] , and a DIV that consume the partial view result .

I was thinking perhaps a view-result can be encapsulated into a JSON result , and the JSON result will have fields to indicate the success/failure status , and the encoded markup of the partial view result .

View 3 Replies

Button That Performs A Server-side Action And Returns A File To Download?

Jul 28, 2010

I have an ASP.NET page (using ASP.NET AJAX and the Telerik RAD components) that provides a data table and an option to download data in CSV format.I have a requirement that a single button allow the user to download a data set. I have a system set up that's nearly working for me based off the solution in
http://stackoverflow.com/questions/104601/asp-net-response-redirect-to-new-window

<asp:Button ID="ExportCsvButton" runat="server" Text="Download to CSV/Excel"
byte[] csvBytes = someLongOperation();
Session[EXPORTED_SESSION_KEY] = csvBytes;
Response.Redirect("myexportpage.aspx", true);
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AppendHeader("content-disposition", "attachment; filename=" + "file.csv");
Response.ContentType = "text/csv";
Response.AddHeader("Pragma", "public");
Response.BinaryWrite(Session[OtherPage.EXPORTED_SESSION_KEY] as byte[]);
Response.Flush();
Response.End();
}


This actually works quite well. When I click the 'Export to CSV' button, the page's UpdateProgress kicks in and my loading overlay appears (it's a CSS div that covers the window when visible). This can take some time depending on the data set (potentially several minutes), at which point I'm getting a window popup with my file.

View 1 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

System.NullReferenceException: Object Reference Not Set To An Instance Of An Object.

Feb 8, 2010

I am getting error after publishing a website. At debug mode it works fine.

Private Sub fill_ddl_Dist(ByVal _query As String)
Dim con As Connection
con = New Connection

TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

View 4 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

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

AJAX :: Every Method Returns Null?

Feb 19, 2010

had used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,

View 1 Replies

Web Forms :: Datalist Findcontrol Returns Null?

Mar 1, 2010

I have a datalist with price label

<asp:label runat="server" ID="lblPrice" Font-Bold="true" Font-Size="Medium"> <%# DataBinder.Eval(Container.DataItem, "dProduct_price") %></asp:label>

i have used to find the control in my code but when i debug the value is null

Label price = (Label)e.Item.FindControl("lblPrice");

View 1 Replies

DataTable.Rows.Find Returns Null

Feb 13, 2010

I have a DataTable for which a PrimaryKey constraint has been set to be a combination of an integer column and a datetime column. When I try to 'Find' a row by saying,

dtFunds.Rows.Find(iContainerIndex)

I get a null value. iContainerIndex has been defined as an object array of size 2 with the integer ID and date values in it.

When I set a breakpoint in my code, I see that the very same values are present in the datatable.

If I try to execute, DataTable.Select() method with the integer column filter, I get a result - but returns no result when called with the date column filter.

What am I doing wrong here? The very same DateTime value is present in the datatable.

View 1 Replies

C# - Telerik RadComboBox Find Returns Null?

Nov 1, 2010

why the below javascript code always returns null (mean alert) ?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
<telerik:RadComboBox ID="RadComboBox1" runat="server">
</telerik:RadComboBox>
</div>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var combo = $find("<%= RadComboBox1.ClientID %>");
alert(combo);
</script>
</telerik:RadCodeBlock>
</form>
</body>
</html>

View 2 Replies

ADO.NET :: Linq To SQL Returns Null For DateTime Fields?

Aug 17, 2010

I have a linq to sql entity class in which I declared some DateTime fileds like this:

[Code]....

And this is how I fetch data form repository:

[Code]....

All non DateTime fields are filled properly but all datetimes are null.[Column(DbType = "smalldatetime")]

View 8 Replies

AJAX $find Always Returns Null In Usercontrol?

Jul 30, 2010

I want to use multiple targets with my ModalPopUp extender. One of my buttons is set as target in the ModalPopup and the other one will use server-side code to show the ModalPopup.

This is my ModalPopup so far:

<msAjax:ModalPopupExtender ID="modalInform" runat="server"
BehaviorID="modalInform"
TargetControlID="btnSearchUsers" [code].....

Then I found this little tutorial on the ASP.NET AJAX site.But when I use $find("modalInform") in the pageLoad Javascript function (as defined in the tutorial at the bottom), I'm always getting a $find("modalInform") is null error.

This code is included in a usercontrol, the usercontrol is used in a ASPX page and this ASPX-page uses a MasterPage.
I've noticed that if I'm using

<%= modalInform.ClientID %>

I'm getting a different value then defined in my HTML-source (propably because of the MasterPage?).

View 1 Replies

.net - FormView.FindControl() Returns Null Until DataBind()?

Jan 31, 2010

Why method FindControl() returns null on FormView until call DataBind(). After that it returns everything correctly? What workaround are there? Call DataBind() before first call of FindControl() ?

View 3 Replies







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