asp.net-mvc

How do I code this SQL query in Linq-To-SQL?

I'm new to MVC and its going well but struggling a bit with the back to front SQL etc select * from aspnet_Users where Active = 1 and UserId in (select UserId from aspnet_UsersInRoles,aspnet_Roles where aspnet_Roles.RoleId = aspnet_UsersInRoles.RoleId and aspnet_Roles.RoleName = 'Auth Level 1') Tables and fields are: aspnet_Users (U...

asp.net mvc many-to-many one-to-many

Hello, I am new in asp.net MVC, and in Entity Framework to. I watch on asp.net mvc tutorials, but they are very easy. I need to write little site, and in my database have one-to-many reletionship. if i want to select data from two tables (classic inner join), what you recommended to use, db views or Linq to Entity queries. If Ling to Ent...

How can I check if a controller was called using post or get?

In ASP.Net MVC, how can I check in a controller method, if it was called using post or get? I am aware I can limit methods to being called only by post or by get - but how can I check for post/get in a method that allows both? ...

How do CMS upload images?

Hi I am just playing around and trying to make a very simple CMS. Right now I what I do right now is I use "FtpWebRequest" to get the file that they want to change around and stick it into a jquery plugin call html area(rich html editor). Now I am wondering how could I allow them to add images that are not already hosted? Ie not on ima...

Editing a big imported file on a second page

This is mostly theoretical question, since I actually can implement it in any way, but it confuses me a bit. So, suppose I present a user with a page to select an Excel file, which is then uploaded to the server. Server code parses the file, and presents the user with another page with many options. The user can select and deselect some ...

How to create a file(.aspx,html,txt) in memory?

Hi I want to create a file with a .aspx extension(or any other extension) completely in memory. Can this be done? Right now I have a memory stream that has all the stuff I want to write to this file but I don't actually want to create a physical file on the server since then I probably have to enable write permissions for my server. W...

What is the appropriate route design for this ASP.NET MVC application?

My url http://server/region/section/item Now if someone goes to http://server/us/ I want to display a page to choose a section if someone goes to http://server/us/beer/ I want to display a list of all beers. My question is should I just have 1 route with defaults and then return different views depending on how much the URL is filled i...

Getting Back a 501 Syntax error when I upload via ftp requests through code

Hi I keep getting this error when I do some ftp requests through my C# code using ftpWebRequest System.Net.WebException was caught Message="The remote server returned an error: (501) Syntax error in parameters or arguments." Source="System" StackTrace: at System.Net.FtpWebRequest.SyncRequestCallback(Object obj) at S...

ASP.NET MVC CheckBox

Hi there, I have an MVC view that displays a list of records. I want to have a check box that allows you to hide / show inactive records. How can I make it so that when the user checks / unchecks the box, it hits the controller and gets a full or subset list back? Should I use an AJAX call? Should all this be done on the Index method...

Authentication/Authorization of an ASP.NET MVC Project

We're getting our new MVC project off the ground and are trying to tackle the concerns of authentication and authorization (through Action Filters preferably). Our roles will come across as AD groups (already determined for us) so all we really have to do is read the groups a user is in (from the identity). If you're in one of the grou...

Is it possible to run an ASP.NET 3.5 MVC 1.0 app on a server that supports ASP.NET 2.0 only?

My host supports ASP ASP.NET v1.0/2.0 ASP.NET Ajax Access Database Support MS Server Database Support (SQL Server) I know by copying some of the files it's possible to run a .NET 3.5 Windows Forms application without .NET 3.5 installed on the client. Does the same hold for ASP.NET 3.5 MVC 1.0? Does MVC 1.0 support .NET 2.0? My host ...

Reorganizing ASP.NET MVC Folders

I'm looking to migrate web forms app to mvc. One of the organizational issues I would need to tackle is our folder structure. Currenly it's organized by functional area e.g. Application Functional Area (e.g. MyAccount) Task 1 (Manage Notifications) Task 2 (Change Payment Info) etc.. Functional Area Task 1 Task 2 etc.. which...

MS MVC: Is there a way to separate C# code from markup in MVC views?

Our ad department pumps out Html code that they constantly change (and totally manage themselves). They have no knowledge of JavaScript, let alone C# etc. beyond a purely designer's point of view. Anything in their realm will be purely HTML and CSS (just like InDesign is to PostScript printing). All of this is really as it should be (...

Problem running ASP.NET MVC in IIS7

I am running my ASP.NET MVC application in IIS7 it gives the below error. Same thing works fine in IIS6 Could not load file or assembly 'System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exc...

How to Validate fields when calling Json post method to save data?

I'm working in an ASP.NET MVC application. In that I need to save records(example: Name, Email, comments) using Json request. I don't have any form tag and submit button on my page. So I'm calling Javascript method on button click event to save my records asynchronously. I'm not able to use jQuery's validate plugin. Is there any jquery c...

form timeout in ajax

I'm having a mvc application which i use form timeout. But i use ajax form all around the page. So whn i make a ajax form post after timeout it gets the login page. But i need to redirect the page even it is an ajax call. How can i check the form timeout in JavaScript. ...

How do I warn the user that their web session is about to time out?

I've checked around for a solution but I don't seem to get any directed to asp.net mvc. Basically I'm looking for a solution where a user is notified a minute before the session expires. The ideal solution will be count down notification that will have an option to renew the session. If the countdown timer expires without the user ref...

ADO.NET Entity Data Model - MVC - managing one-to-many relations

Let's say that I have following situation. I have many customers and many consultans, and each customer has attached only one consultant. So it's one-to-many relationship. I created Edit view which display customer_name and customer_consultant_id how should I update information after post? Just UpdateModel does not work, so something m...

How to return XML from c# to JQuery

My program is giving me an error from jquery. I don't understand why. I works in c# but in jquery it does not using (XmlTextWriter writer = new XmlTextWriter(new StringWriter(sb))) { writer.Formatting = System.Xml.Formatting.Indented; ser.Serialize(writer, ct); XMLContent = sb....

Cannot use fluent html lambda expressions in Spark view

I'm attempting to use fluent html and the spark view engine in my asp.net mvc application. I've assinged the proper base class, added the assemblies, and when i do this.TextBox("MyProperty") it works fine. However I get the below exception when i attempt to use this.TextBox(m=>m.MyProperty). Any idea what can be causing this? Exception...