Tech blog

Solving problems

About
Contact

Archive for the ‘ASP.NET MVC’ tag

PDF files not Publish in ASP.NET MVC when deploying

leave a comment

We faced a problem when we added some PDF files into our media library of ASP.NET MVC website and noticed that these files are not Published automatically.
So you need in Visual Studio to click on each PDF file and under Properties (F4) just choose

  • Build Action=Content
  • Copy to Output Directory=Copy Always
VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)

Written by Avivo

June 1st, 2010 at 1:28 pm

Comparison: ASP .NET WebForms vs MVC

leave a comment

Comparison: ASP .NET WebForms vs MVC

WebForms MVC
  • Requires .NET 2.0
  • Event model – button click triggers an event in code-behind
  • ViewState – server-based forms for easier management
  • Existing third party controls
  • Requires .NET 3.5 and MVC library
  • Requires IIS 6.0 or later for URL rewritting – btw, max IIS version for WinXP is 5.1
  • Backward compatible – developer can include WebForms pages into MVC website and vice-versa
  • Dividing an application into the model, the view, and the controller – data, design and code are separated
  • For large teams of developers and designers (parallel work)
  • No ViewState means smaller output and cleaner html
  • Portable among other languages (like php) – similar file hierarchy, object names, different syntax
  • 30-50% faster than Web Forms, 100-800 requests per second
  • Native URL rewritting
  • Skinnable, suitable for websites that are viewed in computer browsers and mobile browsers
  • Unit testing
  • VN:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.3_1094]
    Rating: +3 (from 3 votes)

    Written by Avivo

    January 30th, 2010 at 11:41 pm

    Could Not Load Type in ASP.NET MVC

    leave a comment

    If you got this message you have missing web.config in Views directory.

    You have this file in your development project – click on it in Visual Studio and set to Copy Local, so it will be copied when you click Publish.

    VN:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.3_1094]
    Rating: 0 (from 0 votes)

    Written by Avivo

    November 30th, 2009 at 5:39 pm

    Hosting ASP.NET MVC on IIS7 and “Could Not Load Type” error

    one comment

    1. If you want to host ASP.NET MVC on IIS7 don’t forget to copy also MVC DLLs to bin directory when publishing.
      • If you have ASP.NET 3.5 SP1 installed on server copy only System.Web.Mvc
      • If you don’t have ASP.NET 3.5 SP1 installed on server copy
        System.Web.Mvc
        System.Web.Routing
        System.Web.Abstractions
    2. You need to copy also web.config that is under directory where your Views are – it is not included in your project by default so it will not be published. Copy this manually or include this web.config in your project and then Publish.
    VN:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.3_1094]
    Rating: 0 (from 0 votes)

    Written by Avivo

    September 14th, 2009 at 4:15 pm

    SelectedValue not working in ASP.NET MVC

    leave a comment

    <%= Html.DropDownList(“Salutation”, (IEnumerable<SelectListItem>)ViewData["Salutation"])%>

    We just did not use properties in our viewdata that had the same name as any of the dropdowns , so above example is wrong and it will not select value properly. Instead of this use something like this:

    <%= Html.DropDownList(“Salutation”, (IEnumerable<SelectListItem>)ViewData["SalutationList"])%>

    And in controller:

    ViewData["SalutationList"] = new SelectList(userModel.Salutations, “Value”, “Title”, user.Salutation);

    VN:F [1.9.3_1094]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.3_1094]
    Rating: 0 (from 0 votes)

    Written by Avivo

    August 17th, 2009 at 3:27 pm