MVC :: Model Instance Hang Around For A While?

Jun 26, 2010

I've used mvc for a few weeks now, and just realized that my controller constructor is invoked on every action, and that's where a model is typically instantiated in the examples I've seen, so the model never lives beyond one request. I have older third party db and it seems that some judicious in-memory state management would make sense in my intra-net app. It seems like a true classic mvc app ( non-web oriented) would allow for retention of model instances in-memory (one fundamental repository behavior is in-memory collection - re: M.Fowler). I am not able to use Entity Framework, and a little curious if it does some caching instead of always immediately persisting to db, thereby providing that repository behavior. Do I have to save my model instance to the ole Session / TempData object to retain it in memory across *numerous* controller actions? Or does this implementation absolutely require some other mechanism like NHibernate? Seems like just keeping something

View 1 Replies


Similar Messages:

C# - ThreadPool.QueueUserWorkItem Causes App To Hang Until Finished?

Dec 10, 2010

This may be due to a lack of understanding of what's going on under the hood or simply a lack of understanding of threading in general. When a user logins I need to run some tasks that call web services to update data in my system. Since the services could take a considerable amount of time I thread the entire process. However, even though I think I'm running the whole series of tasks in a thread separate from my application, my application waits until the called function is finished before it proceeds.

WindowsIdentity identity = WindowsIdentity.GetCurrent();
Manager manager = (Manager)Session["Manager"];

ThreadPool.QueueUserWorkItem(new SafeWaitCallback().Call(identity, delegate(object noCallBack)
{
manager.RunAccountUpdater(identity);
}));

The application hangs until the function "RunAccountUpdater" is finished and the callback occurs. What am I doing wrong/not understanding?

View 1 Replies

Hang Of Importing Data From A Database Onto A Website

Jul 30, 2010

I've pretty much gotten the hang of importing data from a database onto a website using asp.net, now I want to do the reverse.I want a site that the user logs into and makes 4 different selections from 4 drop-down lists and those choices are recorded onto the database. I've worked out the log in part (it was actually really easy...) but I wanted to know a good source to learn about exporting data.

View 3 Replies

AJAX :: Hyperlinking From Gridview On Popup Cause Hang?

Jan 8, 2010

I am battling a strange error. I have a form, formA, that has a modal popup extender to show a panel containing a gridview. One of the columns on the gridview is a link button that launch a new form, formB, in a new window (ie. the link contains target=_blank).

The code runs as expected. That is, the modal popup displays the grid and clicking the hyperlink launches the page in a separate window. When you close the new page's window, as expected formA is still displaying the modal popup. If you close this modal popup it goes away as expected. Now, the wierd part. If you click on a control on FormA that causes a postback, the load event fires, but the postback event (ex button_click) handler is never called. The app is essentially hung. The only way to regain control is kill the application. This hang only occurs if you click on the hyperlink. If you just open and close the modal popup there are no problems.

View 1 Replies

Web Forms :: Response.redirect Causes Browser To Hang?

Feb 18, 2011

I've created a new web application in Visual Studio 2008. Then I added a button, and in the Button1_Click event I put a redirect statement to a website. This is the only code I've added to the default app. But when I run this application on my development server and click on the button, a browser window opens and then permanently hangs without showing the page content.This is a simplified version of a problem I'm having in another app. I can't get past this. Why does this resonse.redirect statement cause the browser (I'm using IE8 and Windows Vista) to hang?

Protected
Sub Button1_Click(ByVal
sender As
Object,
ByVal e
As EventArgs)
Handles Button1.Click
Me.Response.Redirect("http://www.microsoft.com")
End
Sub

View 2 Replies

C# - MonoDevelop Seems To Hang (not Unresponsive) When Building Csprojs

Mar 7, 2011

I'm hoping someone else has experienced this and has some suggestions. The actual dcms process goes pretty quickly, but in between projects it hangs after printing: Building: XXX.YYY.ZZZ (Debug) After a few minutes (been 10 so far on this current run), it jumps to:

Performing main compilation...
/Library/Frameworks/Mono.framework/Versions/2.10.1/bin/dmcs /noconfig "/...
Build complete -- 0 errors, 0 warnings
Building: XXX.YYY.ZZZ (Debug)

Then hangs again for another few minutes. This is a sln file with 29 csproj projects in it that was originally created in Visual Studio 2010. I'm wondering if there is a better way to set this up - potentially a native MD file format?

View 1 Replies

C# - Errors In Razor Pages Cause Server To Hang?

Feb 8, 2011

I've been writing an app using the awesome new Razor view engine and for the most part, things have been great.

One issue I keep running into, however, is that if I should happen to write invalid code, such as referencing a null property or even a non existent property, rather than throwing an error, something happens in the background that causes the browser to wait and wait and wait and if I do not cancel the browser's request quick enough, IIS will simply hang.

It seems as if it enters some sort of loop. CPU usage goes up (though not terribly high) and restarting IIS via either GUI or iisreset command seems to take abnormally long (presumably while it waits for the process to safely shutdown).

This also happens for other invalid code scenarios such as failing to close a code block with a closing brace.

View 1 Replies

Visual Studio :: Vs Asp2008 Instance Cant Recognize SqlExpress 2008 Instance On Machine

Feb 6, 2010

vs asp2008 instance cant recognize the sqlExpress 2008 instance on my machine

I have wonder if you could try to help me with the fallowing issue:When trying to add a new sql server connection (local or remount) from VS(visual studio) 2008 express - on the add connection dialog

box: server name: are Empty!!
The vs couldn't point to any database, like dont recognize the sqlExpress 2008 instance i got on my machine.

1. Have tried to "play" with sa property's(from sqlS: Databases: security: login tree folder) and with the sql

s windows service: stop and restart
2. And so with the target db.
3.

On the services.msc
The sql server express the status is started.
The sql server agent status is disabled and don't have the option to start.
The sql server explorer status is disabled and don't have the option to start.

4. And so reinstalled the asp.

View 2 Replies

MVC :: Store Model In Separate Class Library- Pass Model Objects?

May 19, 2010

I'm building an MVC 2 RTM app, and I want to be able to share my model across applications. I'd *like* to be able to implement it like:ASP.NET MVC2 app (holds Views and Controllers)Class library to hold Model(s)WCF app to handle the data transactions with the models via different data stores across apps I had the MVC app working fine, but I wanted to abstract the data stuff and be able to work with the model across apps through the WCF site, so I created a class library project and moved all of the Models classes into that and set-up a WCF app, then added project references to the MVC and WCF apps that point at the class library. The idea was I can create services that take and return objects from the model via method calls across apps. It appears that everything's wired up correctly in the MVC project, so I'm passing the objects stored in the Models class library between controllers and views and everythig is compiling just fine, but for some reason the data is not being passed back from the views to the controller on POST -- all of the properties in the classes are null or empty.

When I debug the app, I can see that the values are stored in the model data dictionary but not the model object itself. What am I doing wrong? Am I on the wrong path, or missing something obvious (to some)?

View 2 Replies

MVC :: Access Model Validation Inside Custom Model Binder?

Sep 1, 2010

Is it possible, inside a Custom Model Binder, to fire "something" that "says" the value is invalid so it gets handled by validation part?

Basically, I am getting an exception when the value for the property is invalid.

View 1 Replies

ADO.NET :: Entity Model - Update Model From DB And The Assembly Reference Seems To Be Missing?

Jan 10, 2011

I made a few changes to the DB in SQL server management studio then right clicked on the .edmx doc to get it to update. That seemed to work fine but when i compiled the app everything that referenced the EF seems to be broken.The Error list now contains the below error for all classes that used it.

The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)

View 4 Replies

HttpHandlers / Modules :: Process Model Or Thread Model Of A Website?

Mar 11, 2010

I have an issue of static variable in an asp.net application. Let's say I have a server with 8 CPUs running windows 2008 R2 hosting an asp.net webbsite, nothing fancy here, no funny configuration.

Is the following statement true? at any single time, there's one and only one process is running and accepting requests, even in the recycling stage. The reason I am asking is: I have a static field in my class, and I want to make that's the only static instance in the website. I've heard in some circumstances, IIS is recylcing your application, and it will start a new process, but the old process is still working, thus I will have 2 static instances in memory, which defeat the purpose of static field.

One step further, let's assume there might be 2 instances in memory, can I assume there are at most 2 instances at any single time? And can I assume once the second instance is up, the first instance will NEVER accept new requests?

Another question: Recently I have a problem with an applicationdomain concept. Looks like if an application domain causes a memory leak, unload the domain will not release the memory (Umanaged leak). So to what extent Application Domain is isolated?

View 1 Replies

Default Model Binder Does Not Bind Model Class

Dec 28, 2010

I am trying to make a post that should use the Default Model Binder functionality in ASP.NET MVC 2 but unfortunately I can't get through. When I click on the checkout button I populate a form dinamically using jQuery code and then submit this form to the server. This is the form that get submitted

<form action="/x/Order/Checkout" id="cartForm" method="post">
<input name="__RequestVerificationToken" type="hidden" value="UDjN9RdWheKyWK5Q71MvXAbbDNel6buJd5Pamp/jx39InuyYIQVptcEubIA2W8DMUzWwnZjSGkLspkmDPbsIxy8EVuLvfCSZJJnl/NrooreouptwM/PaBEz2v6ZjO3I26IKRGZPqLxGGfITYqlf8Ow==">
<input id="CustomerID" name="CustomerID" type="hidden" value="1">
<input id="FirmID" name="FirmID" type="hidden" value="2">
<input type="hidden" name="CartItems[0].ServiceTypeID" value="1">
<input type="hidden" name="CartItems[0].Quantity" value="1">
<input type="hidden" name="CartItems[1].ServiceTypeID" value="2">
<input type="hidden" name="CartItems[1].Quantity" value="1">
</form>

This is the jQuery code that handle the submit event for the form
$("#cartForm").submit(function (event) {
event.preventDefault(); var form = $("#cartForm");
var panel = form.parent(); panel.parent().block();
$.ajax({ type: "post", dataType: "html",
url: '<%: Url.Content("~/Order/Checkout") %>',
async: false, data: form.serialize(),
success: function (response, status, xml) { panel.parent().unblock(); },
error: function (response) { panel.parent().unblock(); } }); });

This is the controller action that should be get called
[HttpPost]
[ValidateAntiForgeryToken]
public virtual ActionResult Checkout( CartModel cart ) {
} And finally this is the CartModel class involved
public class CartModel : BaseModel{
public int CustomerID { get; set; }
public int FirmID { get; set; }
public List<CartItemModel> CartItems { get; set; }
public CartModel() { CartItems = new List<CartItemModel>();
} } public class CartItemModel : BaseModel
{ public int ServiceTypeID { get; set; }
public int Quantity { get; set; } }

But the default Model Binder does not bind the web form data to a CartModel class. Using Fiddler I have been able to see that the data sent to the server is correct as you can see from the following snapshot.

View 1 Replies

MVC :: Model State Doesn't Contain Model Values

Aug 2, 2010

when I use Html.HiddenFor( model => model.OwnerId ) to create a hidden field, the value assigned to that field is zero. When I use <input type="hidden" value="<%: Model.OwnerId %>" /> to add the hidden field to the form, the value is assigned correctly.

Why would Html.HiddenFor( model => model.OwnerId ) not get the correct value from the Model object? Am I supposed to load model state somehow separate from returning the model object from the action method? Here is the view:

[Code]....

The Create action method is relatively straight forward.

public ActionResult Create( ... )
{
ViewStockItem item = new ViewStockItem();
item.ActionCode = ActionCode.Add;
if (item.OwnerId == 0)
item.OwnerId = 7;
BookOwner owner = db.BookOwners.Single(c => c.OwnerId == item.OwnerId);
item.OwnerName = owner.OwnerName;
return View(item);
}

View 4 Replies

Should Data Annotations Be On The Model Or The View Model

Dec 15, 2010

I've been used to decorating data model classes with data annotation attributes, but the purist in me baulks slightly at including purely presentational attributes such as display format here. I am, however, quite happy to keep validation centric attributes here. One good reason I have to continue keeping all annotations etc. in the data model is that my view model aggregates data model classes, e.g.

my ViewModelBase.DetailItem<TEntity> property in the view model is just a reference to an entity class in my data model. If I wanted to move presentational annotations to the view model, I would have to quite radically revise my design to one where I duplicate data model properties in my view model and use an object mapping tool to populate view model objects based on data model objects.

[code]....

View 2 Replies

MVC :: View Model To Convert To Domain Model?

May 4, 2010

Say I got a domain model as follows: (and my repository expect an instance of this object)

[Code]....

And a view model (which my views are based on)

[Code]....

At the moment I got it like this and have my controller action manually create a new Person object from the PersonModel object before passing it on to the repository, which does not feel right.

So I tried to have PersonModel inherit from Person and pass that to the repository (also tried casting the PersonModel to a Person object first), but that don't work out.

What's the right way to have PersonModel automatically cast to Person? I want to keep this logic as my current structure allow me to keep things really loosely coupled, with the repository layer not having a clue how it's being used.

View 1 Replies

MVC :: Validation Of Model In Side Model

Oct 12, 2010

I have recently started working on ASP.NET with MVC 2 framework, and I am facing following difficulty in validating my data,

Scenario:

In my application the view (ASPX) is divided into tabs (jQuery) and each tab's content is ViewUserControl (ASCX). The main model for the view has collection of sub models for individual tabs. I use RenderPartial method to render view user control.

[Code]....

And the user control (Tab1.ascx) refers the specific model for it,

[Code]....

Now if in my Tab1Model if I put following validation

[Code]....

In the controller ModelState.IsValid is always indicates TRUE. How do I override the validation behavior such that it as well looks the items in the collection member (which holds sub models) as well.

<%= Html.ValidationMessage("FirstName") %>

View 1 Replies

MVC :: How To Use Attribute [Display(Name="")] For Model That Comes From An Entity Data Model

Mar 15, 2011

I am a newbie in mvc3 and i'm wondering how to use attribute like [Display(Name="")] for model that comes from an entity data model that I provide im my "Model" folder in my mvc3 project.

I didn't provide a .cs class for each of my database tables .

other words, I want the controller class render a edit form for me like :

First Name:--- instead of : fName:---

View 9 Replies

Model View Control Versu Model View Presenter

Jun 2, 2010

I have been reading about different model for development

model view control mvc

model view presenter MVP

Model view view model MVVM

i belive MVC has two big Advantage over webform 1) TDD 2) More control on HTML

MVP is bit variation in mvc model. rapid development as well as 1) TDD 2) More control on HTML (correct me if i m wrong) see the below link

[URL]

View 7 Replies

AJAX :: To Authenticate A User Using Model Popup Extender / Model Popup Extender Popup Panel Keep Visible

Feb 18, 2010

I want to authenticate a user using model popup extender. So I wrote a program to do this. Everything OK when user enter the correct details. But user enters the wrong detail, it should shows in a lablel in a popup panel. It shows; but the problem is it close the popup . But I want to keep the popup if the user enters the wrong details. How can I do this?

View 5 Replies

Jquery - JavaScript Int Variable From MVC Model Data / Get Model Data Into A JavaScript Variable

Jan 11, 2011

I need to get model data into a JavaScript variable and use it as an int to compare values. But I can only figure out how to get the model data as strings, otherwise the compiler complains.

So how can I get the max and taskBudgetHours as int variables in the Javascript?

[code]....

View 2 Replies

SQL Server :: How To Create The New Instance Along With PC Name

Sep 26, 2010

I have a question regading sql name instance ???

When ever i create new instance in sql server 2005 , it use to create the new instance along with my PC name.

For Eg :

My PC Name is Web and New instance name is Busiwork it use to create like WebBusiwork. But i need just the sql instance name of my server as Busiwork.

View 5 Replies

How To Create New Instance Of An Object

Aug 5, 2010

As some may be aware, I recently posted about high memory usage on my website and I have an idea that my thumbnailer may have something to do with this as I am not actively disposing of the instance when it has been used due to my misunderstanding how it works.

I am now looking at my code for the thumbnailer and would like some advice on when something would actually need disposing of, is it ONLY when you create a new instance of an object?

Like:

Target := System.Drawing.Bitmap.Create(Trunc(Width), Trunc(Height));
MyImage := Target.FromFile(PhotoPath);

So, my question would be, do I need to dispose of both Target and MyImage to make sure the GC does what it needs to do properly?

View 4 Replies

C# - How To Create Instance Of A Class Only Once

Apr 4, 2011

A instance of a class is created in the partial class of an aspx page.Under page_load or button click method I'm trying to set the value to the class. but when each postback takes place new instance is created and I'm losing the previous value.

public partial class DatabaseSelection : System.Web.UI.Page
{
DBProperties dbpro;
Metadata obmeta;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dbpro = new DBProperties();
}

View 4 Replies

C# - Check Whether A Instance Is Serializable?

Nov 12, 2010

How can check whether a instance is marked as serializable?

View 4 Replies







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