asp.net-mvc

cookie not deleting

I am using the following code to set a cookie in my asp.net mvc(C#) application: public static void SetValue(string key, string value, DateTime expires) { var httpContext = new HttpContextWrapper(HttpContext.Current); _request = httpContext.Request; _response = httpContext.Response; HttpCookie co...

How to Detect Select n+1 problems in Linq to SQL?

What is the best way to detect Select n+1 problems if i am using linq to SQL, right now we are working on a project and it seem to be pretty slow to display some lists. What is the best method to detect this? ...

Rename ReturnUrl literal in asp.net mvc

I put the authentication attribute that sets: filterContext.Result = new HttpUnauthorizedResult(); so when I try to access http://www.mysite.com/Forum/Polls and I am not authenticated I am redirected to: http://www.mysite.com/Account/Log?ReturnUrl=%2FForum%2FPolls I want to have the following line instead: http://www.mysite.co...

Ashx file creating images in MVC ASP.net

Hi All, I am dynamically creating images and need to show those images to users. For that i have created a ashx file but the problem is this ashx file is never getting called not sure why path issue or need add any tags in web.config .. while debugging its not going .. might be its not finding please advice. EDIT: When i directly ...

Do the Nerd Dinner models use best practices for disposing objects?

I've been looking at the Nerd Dinner code and one thing they do in their models, is create an instance of the DataContext like this: public class DinnerRepository { private NerdDinnerDataContext db = new NerdDinnerDataContext(); public IQueryable<Dinner> FindUpcomingDinners() { return from dinner in db.Dinners ...

using NerdDinner as an example, when should the DataContext be disposed

I noticed that NerdDinner doesn't dispose of the DataContext -- ever. That seems very strange to me. They have a Repository class that creates a private member of the data context, which hangs around for the lifetime of the repository class -- and who knows how long that is, since it's created at the time of the controller's constructi...

ASP.NET MVC Application in Sharepoint 2007 virtual directory.

Hi, I have MOSS 2007 installed at lets say http://localhost:4999/ and I want to have my custom ASP.NET MVC (1.0) application at http://localhost:4999/mvcapp/ - logic dictates that, in IIS, i should create a new application virtual directory under my MOSS site and point it at my custom MVC app. I've done this and it works for executing...

What happened to MVCContrib Subcontrollers

I see several articles on the interwebs about MVCContrib's subcontroller feature, but I don't see anything on the codeplex site about it. Has this feature been supplanted by something in MVC2? Whats the best approach for rendering controls with their own data pipeline (submit to their own controller, display data from their own contr...

find the hidden field

Hi All, I have a table with an image on each row with a hover event attached. Can someone please show me how to alert the value of the hidden field? <div class='first'> <input type="hidden" value="target"> <div class='second'> <img src="yada" /> </div> </div> thanks, rodchar ...

Silverlight and ASP.NET MVC living together in the same team?

Let's say you have an intranet development team where it is in your best interest for each developer to be happy with their work - one person leaving will negatively impact the others. Some developers wish to embrace the Web (i.e. ASP.NET MVC). Others wish to work in a stateful environment where Web is merely the medium for delivery (i...

How to make my own Attribute tag?

Hi I am using asp.net mvc 1.0. I know asp.net mvc has a couple attribute classes such as "AuthorizeAttribute", ActionFilter? and I think there is like 2 more. So I have made my own AuthorizeAttribute but I am not sure if this is the right one to use again or if I even need to inherit any of these built in classes. What I am trying to...

How can I find which object in ASP.NET can't be serialized?

I'm getting the following error in my application: Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is ...

Mixing ASP.NET MVC into ASP.NET WebForms

For some reason my routing is ignoring any attempt to access my MVC pages and simply giving me 404s. I have a WebForms app set up like the following: Virtual Directory: thing So I usually access my site like so: http://localhost/thing/someFile.aspx http://localhost/thing/someFolder/anotherFile.aspx The original stucture of my A...

How do you use Models in a master page with ASP.NET MVC?

public ActionResult Index(){ var dataContext = new DataEvidencijaDataContext(); MembershipUser myObject = Membership.GetUser(); string KorisnickoIme = myObject.UserName.ToString(); var user = from i in dataContext.korisniks where i.korisnik1 == KorisnickoIme ...

ActionLink with parameter after ? instead of /

Hello. Please give me example how to generate ActionLink with reditection to: http://localhost/Articles?View=xx instead of http://localhost/Articles/View/xx ? Im doing this like as follow (and it's give me first type of redirection): <%= Html.ActionLink("View this article", "View", "Articles", new { id = Model.Item.Slug }, null)%> ...

How do you return something in a ActionFilterAttribute?

Hi I am trying to use the ActionFilterAttribute in asp.net mvc. What I want to do is check if the users subscription is expired if it is I want to redirect the user to a page if not then do nothing. But the methods that you can override are all void. So how do I do this? Like I don't even know how to unit test it either since it is voi...

Can't get jQuery autcomplete to work. (ASP.NET MVC)

Hi, I'm trying to follow the example in this post by tvanfosson. I just can't get it to work. I think the problem is with my JavaScript (?). I say that because if I navigate in my browser to http://localhost:49790/Books/GetBooks/?q= then the browser downloads a file with the information that I'd expect in the format I'd expect: [{"Boo...

Install asp.net mvc 2 beta on Visual Studio 2010 Beta2

Is there any workaround on installing asp.net mvc 2 beta on a VS2010 Beta2 box?. Phil said on his post that it isn't supported for VS2010 beta2, mostly because of the tooling support and stuff... But what If I just reference the DLL??!!!!! ...

Is there a way to read from Response Headers without getting a PlatformNotSupportedException?

Hello, I am working on an Filter Attribute for ASP.Net MVC that will return a 304 response when the content has not been modified. It would be handy to be able to read the Last-Modified header value set in the Controller in order to accomplish this... there just seems to be one problem. I can't seem to find a way to read the headers when...

Regex for extracting second level domain from FQDN?

I can't figure this out. I need to extract the second level domain from a FQDN. For example, all of these need to return "example.com": example.com foo.example.com bar.foo.example.com example.com:8080 foo.example.com:8080 bar.foo.example.com:8080 Here's what I have so far: Dim host = Request.Headers("Host") Dim pattern As ...