Tag Archives: IIS

[RESOLVED]MVC file storage best practices

Hey guys, I just wanted some quick feedback as this is my first time dealing with file storage and I’d like to do it properly.

I’ve got public downloads. They are available if under the right role. My plan was to store them in a database. Have a back end where the client can update existing downloads. (We usually have monthly new version releases). The size of all the files can’t
be more than 2GB.

I’ve read that storing files on the web server can be a security risk, and that I should have a separate service for file serving. This seems like a bit of overkill for what I need.

I’m not looking for instructions on how to store on a database, I’ve got that figured out. Just want to make sure I’m approaching this the right way. Could be overthinking it as well.

Thanks.

adam3039

Could be overthinking it as well.

Of course. Anyway, SqlServer have FileStream column

http://technet.microsoft.com/en-us/library/bb933993(v=sql.105).aspx

Hi adam,

For this requirement, you also could consider using the FTP to manage files. You could have a server that used to storage files, then configure a FTP site in the IIS.

After that you could upload the files to the FTP server.

# How to: Upload Files with FTP

http://msdn.microsoft.com/en-us/library/ms229715(v=vs.110).aspx

Best Regards

Starain Chen

adam3039

I’ve read that storing files on the web server can be a security risk

As per your description, you are storing the files in the database and not in the web server. Is this correct? In that case you are already using database service for file serving :)

As web servers are outside the firewalls they more vulnerable for attacks. Hence people recommend to put the files inside the firewall and use some kind of service to deliver the files. In your scenario you can have your database inside the firewall and
deliver the files to the webserver. 

[RESOLVED]How to increase ScriptTimeout in MVC5

Hi, i got a problem when i try to upload an image bigger than 4,8 MB, the page goes in time out.. i guess…

error :

[HttpException (0x80004005): Maximum request length exceeded.]

I tryied to add this code in my web.config

<location path="Creation/CreationUpload">
    <system.web>
        <httpRuntime executionTimeout="1000"/>
    </system.web>
</location>

but it does not work

this is the code in my controller :

// POST: /Creation/CreationUpload
        // Afin de déjouer les attaques par sur-validation, activez les propriétés spécifiques que vous voulez lier. Pour 
        // plus de détails, voir  http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [Authorize]
        [ValidateAntiForgeryToken]
        public ActionResult CreationUpload([Bind(Include = "CreationId,CreationTitle,CreationPhotoBis")] Creation creation, IEnumerable<HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
               
                
                // update each field manually
                foreach (var file in files)
                {
                    if (file != null)
                    {
                        if (file.ContentLength > 0)
                        {

                            var myuploadextension = Path.GetExtension(file.FileName);

                            if (myuploadextension.ToUpper() == ".JPEG" || myuploadextension.ToUpper() == ".JPG" || myuploadextension.ToUpper() == ".BMP" || myuploadextension.ToUpper() == ".PNG" || myuploadextension.ToUpper() == ".GIF")
                        {


                            var sizeMb = (file.ContentLength / 1024f) / 1024f; //file.contentlength is in bytes

                            var todaydate = DateTime.Now.ToShortDateString();
                            var todaydatefriendly = todaydate.ImageFriendly();
                            var myuploadiwthoutextension = Path.GetFileNameWithoutExtension(file.FileName);
                            var myuploadiwthoutextensionfriendly = myuploadiwthoutextension.ImageFriendly();
                            var UserId = User.Identity.GetUserId();

                            var fileName = todaydatefriendly + "-" + UserId + "-" + myuploadiwthoutextensionfriendly + myuploadextension;

                            var path = Path.Combine(Server.MapPath("~/Content/UserCreations"), fileName);
                            file.SaveAs(path);

                            //Language
                            var actualculturetocheck = "en";
                            var actualculture = this.Session["ActualCulture"];
                            if (actualculture != null)
                            {
                                actualculturetocheck = actualculture.ToString();
                            }

                            
                            //Ipaddress
                            var ipAddress = Request.ServerVariables["REMOTE_ADDR"] + " " + Request.UserHostAddress;

                            creation.UserId = User.Identity.GetUserId();
                            creation.CreationLanguage = actualculturetocheck;
                            creation.CreationVisible = true;
                            creation.CreationDelete = false;
                            creation.CreationDate = DateTime.Now;
                            creation.CreationIpAdress = ipAddress;
                            creation.CreationPhotoBis = fileName; //after add

                            db.Creations.Add(creation);
                            db.SaveChanges();



                        }


                        }
                    }
                }

                //UserId
                return RedirectToAction("CreationList", "Creation", new { UserId = User.Identity.GetUserId() });
            }

            return View(creation);
        }

what should i do to increase the ScriptTimeout in my contorller action?

FULL ERROR WHEN I TRY TO UPLOAD :

[HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +9553280
   System.Web.HttpRequest.GetMultipartContent() +63
   System.Web.HttpRequest.FillInFormCollection() +165
   System.Web.HttpRequest.EnsureForm() +75
   System.Web.HttpRequest.get_Form() +12
   System.Web.HttpRequestWrapper.get_Form() +9
   System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase request) +121
   System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +37
   System.Web.Mvc.HttpPostAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +39
   System.Web.Mvc.ActionMethodSelectorBase.IsValidMethodSelector(ReadOnlyCollection`1 attributes, ControllerContext controllerContext, MethodInfo method) +54
   System.Web.Mvc.ActionMethodSelectorBase.RunSelectionFilters(ControllerContext controllerContext, List`1 methodInfos) +124
   System.Web.Mvc.ActionMethodSelectorBase.FindActionMethods(ControllerContext controllerContext, String actionName) +142
   System.Web.Mvc.ActionMethodSelectorBase.FindActionMethod(ControllerContext controllerContext, String actionName) +104
   System.Web.Mvc.Async.ReflectedAsyncControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +54
   System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +16
   System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +114
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +468
   System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__3(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Thanks

grafic.web

[HttpException (0x80004005): Maximum request length exceeded.]

This error is related to the size of the uploaded file. You need to increase the Request length

 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

For IIS versions older than 7 use this

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

If you are going to be working with files that are larger than the default of 4MB, you’ll need to update the maxRequestLength within your
web.config to handle files of that size. This can be handled within the <system.web> section of your web.config or the <system.webServer> section if you want to handle it at the IIS level (both are probably a good idea).

It’s important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you’ll need to adjust them accordingly if you plan on handling much larger files : 

<configuration>
    <system.web>
        <!-- This will handle requests up to 30MB -->
        <httpRuntime maxRequestLength="30720" timeout="3600" />
    </system.web>
</configuration>

<!-- IIS Specific Targeting (noted by the system.webServer section) -->
<system.webServer>
   <security>
      <requestFiltering>
         <!-- This will handle requests up to 30MB -->
         <requestLimits maxAllowedContentLength="31457280" />
      </requestFiltering>
   </security>
</system.webServer>

If you don’t see these sections within your existing web.config file, you’ll simply need to copy them in.

How to solve Error : Could not copy … Exceeded retry count of 10. Failed.

hi

i have a MVC web application. its name is StartWPTFramework.

when i run my program it runs iis express and show my website correctly.

when i stop application , iis express and my application remains running. now if i change a little any part of any project in solution and run my program again this error will appear for projects that have been changed.

Could not copy "objDebugStartWPTFramework.dll" to "binStartWPTFramework.dll". Exceeded retry count of 10. Failed.
Could not copy "D:MyFIlesPROWPT.MVC.CMSWPTWPTFrameworkCorebinDebugWPTFrameworkCore.dll" to "binWPTFrameworkCore.dll"

is there any one knows the problem?

You’ll likely want to ensure that your application has stopped running completely. 

You can do this by checking either the Task Manager and looking for any processes related to IIS or your application and stop them prior to editing your application :

This could also be a permissions issues as well. You could try running Visual Studio as an Administrator (Right-click > Run as Administrator) to see if that helps. Additionally, a few users have mentioned this issue as a possible bug within Visual
Studio as seen in this related thread, which might be worth looking through as well.

as i said the IIS and my application in IIS Remain open after stop debugging.

i tried running VS as administrator but problem not solved.

Hi morteza,

After change a project, please clean and rebuild your solution.

On the other hand, please create a new solution with some projects and try again to check the result.

If you still have the issue, please share it to us (OneDrive).

Thanks

Best Regards

i cleaned and rebuilt it but problem not solved.

is there any way to close iis express automatically when i stop debugging? i tried disabling "Enable edit and Continue" but iis express still running after stop debugging.

Hi morteza,

As far as I know the IIS Express won’t stop automatically unless it crash. Also stop debugging the project won’t stop IIS.

Please try to stop the IIS Express manually, then rebuild your project and try again.

Right click IIS Express icon (Notification Area) in the taskbar and click exit.

Thanks

Best Regards

i know how manually stop iis. and as i said before if i stop it the problem will solve. but im looking for a way to stop it automatically.

i think the problem is that after running web application iis load dlls of my project directly from bin folder.

i used this tag in web.config of startProject:

<hostingEnvironment shadowCopyBinAssemblies="true" />

but dlls of dependent projects still load from bin folder.

Could you resolve this issue by change the tag to false? Thank you. 

I tested that if you click stop debugging from the Visual studio. The IISexpress will exit automatically.

Hi Morteza,

It seems there some cross referencing has been done. 

Delete the bin and obj folder. Rebuild the solution again. This will probably solve your issue.

Regards

Pawan

none of this solved my problem.

in my application i load some dlls with Assembly.Load from bin folder.

i think that if i load my dlls from temp asp folder my problem will solve.

is there any way to find the path of dll of specific project in asp temp folder?

Hi,

Pls delete the bin folder and rebuilt the application

[RESOLVED]Route Mapping in Areas

Hi all,

How would I create a route mapping to the following url:

http://localhost/SiteName/AdminCP/Topics/EditTopic/28

AdminCP is an area — I can get to the Topics controller and show a list of topics to the user, then the user clicks a link to edit the topic which should

take them to the url above. EditTopic is a controller in AdminCP which returns a single Index method.

This is my AdminCP registration code which is not working.

 public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "AdminCP_default",
                "AdminCP/{controller}/{action}/{id}",
                new { controller= "Home", action = "Index", id = UrlParameter.Optional }
            );

            context.MapRoute(
               "AdminCP_Topics",
               "AdminCP/Topics/{controller}/{action}/{id}",
               new { controller = "Home", action = "Index", id = UrlParameter.Optional }
           );

        }

Thanks
Melt

Meltdown

ow would I create a route mapping to the following url:

http://localhost/SiteName/AdminCP/Topics/EditTopic/28

It is already created

Meltdown

context.MapRoute(
                "AdminCP_default",
                "AdminCP/{controller}/{action}/{id}",
                new { controller= "Home", action = "Index", id = UrlParameter.Optional }
            );

What is the problem?

Hi Meltdown,

According to your description, you are have the SiteName in your request URL. If you are using the local IIS and create an application (name is the SiteName) under the default web site, then your routing is correct.

If you are just create a website, then you need add the SiteName in your routing. The code would be like this:

 public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "AdminCP_default",
                "SiteName/AdminCP/{controller}/{action}/{id}",
                new { controller= "Home", action = "Index", id = UrlParameter.Optional }
            );

            context.MapRoute(
               "AdminCP_Topics",
               "SiteName/AdminCP/Topics/{controller}/{action}/{id}",
               new { controller = "Home", action = "Index", id = UrlParameter.Optional }
           );

        }

Best Regards

Starain Chen

Hi thanks for the replies, I finally figured this one out.

The simple solution to my problem is to just add an EditTopic action to my Topic controller, but I wanted to maintain the pattern of each
controller only returning a single index action.

The solution is below and it’s important that the EditTopic routing comes before the main generic route.

 public override void RegisterArea(AreaRegistrationContext context)
        {
            
            context.MapRoute(
             "AdminCP_Topic",
             "AdminCP/Topics/EditTopic/{id}",
             new { controller= "EditTopic", action = "Index", id = UrlParameter.Optional }
            );

            context.MapRoute(
                "AdminCP_default",
                "AdminCP/{controller}/{action}/{id}",
                new { controller= "Home", action = "Index", id = UrlParameter.Optional }
            );

            

        }

[RESOLVED]Need help in publishing MVC Application

Hi All,

I have an MVC applicaiton. i want to publish it in IIS and access from the server.

example:

1.  MVC application published in PC1 (windows server 2008)

2. Have to access in PC2 ( Normal PC) connected to the server 

Please help me with this

Thanks

Have you googled how to publish a site or set-up a site in IIS and followed the steps?  There are a lot of walkthroughs on this already, it would help if we knew what you’d already tried and looked at.

Please see this Microsoft’s video on how to publish using Visual Studio

Visual Studio 2013 Web Editor Features – Publishing

Hi AshwinKiran,

First, please refer to pprasannak’s reply.

Secondly, after publish the application to the IIS, you need to add host map (C:WindowsSystem32driversetchosts) in the
PC2 to let it to recognize the domain name or you could bind the website to use IP and access it through IP address.

Best Regards

Starain Chen

I personally would never use HOSTs file.  Use DNS, it’s simple and better to do.

[RESOLVED]Query result that doesn’t make sense (to me)

Hallo , I’m trying  to get  a results base on day of the week  

By doing as follow .

 public PartialViewResult _course()
        {
            int myweekday = 1;

            DateTime dt = DateTime.Now;
            if (dt.DayOfWeek == DayOfWeek.Sunday) myweekday = 1;
            else if (dt.DayOfWeek == DayOfWeek.Monday) myweekday = 2;
            else if (dt.DayOfWeek == DayOfWeek.Tuesday) myweekday = 3;
            else if (dt.DayOfWeek == DayOfWeek.Wednesday) myweekday = 4;
            else if (dt.DayOfWeek == DayOfWeek.Thursday) myweekday = 5;
            else if (dt.DayOfWeek == DayOfWeek.Friday) myweekday = 6;
            else if (dt.DayOfWeek == DayOfWeek.Saturday) myweekday = 7;

            ///for Today
            var _sh = (from c in db.course select c).OrderBy(d => d.daynumber)
                .ThenBy(t => t.Time).Where(w => w.daynumber == myweekday);
            ///for the Next day 
            ///the result here should be 2 (today is sinday and sunday=1)
            ///
            ViewBag.next = (from c in db.course select c).Where(w => w.daynumber == (myweekday + 1))
                            .OrderBy(d => d.daynumber).ThenBy(t => t.Time);

My razor :

 @*the view bag should be null i have only results for sunday and thiis should point to manday*@
                @if (ViewBag.next != null)
                {
                    <h3>tomorrow</h3>
                    foreach (var item in ViewBag.next)
                    {
                        <h3>@ViewBag.Tomorrow</h3>


                        @item.daynumber
                        @item.Writer.Name
                    }
                }

how ever I’m getting the <h3>tomorrow</h3> display  any idea where is my mistake ?

The issue is that your ViewBag may not be null, but may simple exist with 0 items in it. You might want to change the code in your View to check if it is not null and not empty :

@if (ViewBag.next != null && ViewBag.next.Any())
{
       <!-- Omitted for brevity -->
}

You might be able to dramatically simplify your code as you can convert your DayOfWeek value into an integer using the Convert.ToInt32() method as seen below :

public PartialViewResult _course()
{
        // Get the current DateTime
        DateTime dt = DateTime.Now;

        // Since the Day of Week is 0-based, you'll need to increment it by 1
        int myweekday = Convert.ToInt32(dt.DayOfWeek) + 1;


        ///for Today
        var _sh = db.course.Where(w => w.daynumber == myweekday)
                           .OrderBy(d => d.daynumber)
                           .ThenBy(t => t.Time);

        ///the result here should be 2 (today is sinday and sunday=1)
        ViewBag.next = db.course.Where(w => w.daynumber == (myweekday + 1))
                                .OrderBy(d => d.daynumber)
                                .ThenBy(t => t.Time);
}

thanks a lot Mr. Rion,

i’m getting this Error by using Any

‘System.Data.Entity.Infrastructure.DbQuery<MyProjectName.Models.MyClassName>’ does not contain a definition for ‘Any’

 @if (ViewBag.next != null && ViewBag.next.Any())

Try including a ToList() to actually store a collection of your values in memory instead of a DbQuery :

///the result here should be 2 (today is sinday and sunday=1)
ViewBag.next = db.course.Where(w => w.daynumber == (myweekday + 1))
                        .OrderBy(d => d.daynumber)
                        .ThenBy(t => t.Time)
                        .ToList();

Rion Williams

Try including a ToList() to actually store a collection of your values in memory instead of a DbQuery :

///the result here should be 2 (today is sinday and sunday=1)
ViewBag.next = db.course.Where(w => w.daynumber == (myweekday + 1))
                        .OrderBy(d => d.daynumber)
                        .ThenBy(t => t.Time)
                        .ToList();

thanks Rion ,

but no, it’s not null .

john_mm

but no, it’s not null .

Right.

The ToList() call will result in an actual collection of results (in memory) and allow you to use the Any() extension method to check if the collection actually has any elements. You still need the appropriate null check to avoid any null-reference exceptions
when calling the Any() call.

<!-- This ensures that your next collection isn't null and actually contains at least one element -->
@if (ViewBag.next != null && ViewBag.next.Any())
{
     <h3>tomorrow</h3>
     <!-- This will iterate through each value within your collection (which is guaranteed to not be empty) -->
     @foreach (var item in ViewBag.next)
     {
            <h3>@ViewBag.Tomorrow</h3>
            @item.daynumber
            @item.Writer.Name
     }
}
 ViewBag.next = db.course.Where(w => w.daynumber == (myweekday + 1))
                          .OrderBy(d => d.daynumber)
                          .ThenBy(t => t.Time)
                          .ToList();

     @if (ViewBag.next != null && ViewBag.next.Any())
                {
                    <h3>bla</h3>

                    foreach (var item in ViewBag.next)
                    {


                    }

                }

[RuntimeBinderException: 'System.Collections.Generic.List<Hagadol12_8.Models.Course>' does not contain a definition for 'Any']
   CallSite.Target(Closure , CallSite , Object ) +137

john_mm

var stuff = db.course.Where(w => w.daynumber == (myweekday + 1))
                          .OrderBy(d => d.daynumber)
                          .ThenBy(t => t.Time)
                          .ToList();
 

 Validate stuff has stuff in it before working on ViewBag.  Because the viewbag is a dynamic object you’re playing hide and seek with what’s in the View bag.

Separate your concerns by putting all db results into stuff then work on stuffing the Viewbag.  Or better yet don’t even use the viewbag, use strongly typed views.

 

Hi,

john_mm

does not contain a definition for ‘Any’]

If not possible with Any() try with Count

@if (ViewBag.next != null && ViewBag.next.Count > 0)

john_mm

[RuntimeBinderException: 'System.Collections.Generic.List<Hagadol12_8.Models.Course>' does not contain a definition for 'Any']
   CallSite.Target(Closure , CallSite , Object ) +137

The Any() extension method should be available on any IEnumerable collections as long as you are using LINQ either explicitly in your View :

using System.Linq;

or by defining it within the web.config (to be available within your Views) :

<pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Linq" />
      </namespaces>
</pages>

If you are still continuing to encounter issues, you might consider using two of the following options :

  • Consider using the Count() method instead to see if that allows you to perform your check (to see how many values are available in your collection) :
    @if (ViewBag.next != null && ViewBag.next.Count() > 0)
    {
    
    }
  • Or an even easier approach would be to not use the ViewBag at all and actually pass in a strongly typed collection of your values to your View, which would allow you to access them via the Model using :
    // Build your collection of courses
    var courses = db.course.Where(w => w.daynumber == (myweekday + 1))
                           .OrderBy(d => d.daynumber)
                           .ThenBy(t => t.Time)
                           .ToList();
    
    // Pass your courses to your View
    return View("_YourViewName",courses);

    Doing this would allow you to access your courses using a strongly-typed collection instead of a dynamic ViewBag variable as seen below :

    <!-- Define your Model as a List of Course objects -->
    @model List<Hagadol12_8.Models.Course>
    
    <!-- Add your Logic -->
    @if (Model != null && Model.Any())
    {
    
        <!-- Loop through the strongly-typed Course objects in your Model -->
        @foreach (Hagadol12_8.Models.Course course in Model)
        {
    
        }
    }

you are using viewbag as a list data so have to check if there is any element in that list

[RESOLVED]Pageviews per sec

Does anyone have an MVC app running which successfully handles 100-150 pageviews per sec (with output caching)?

That’s our requirement, and I want to know if it is feasible with MVC (assuming we are caching pages). If not on a single server, how many servers did you need?

It depend on how light the pages and how dynamic?

also depends on server machine configurations

stackoverflow

keym6

Does anyone have an MVC app running which successfully handles 100-150 pageviews per sec (with output caching)?

As igna told, StackOverflow is a best example. ( I saw it in one of PhilHaack MVC Video too)

keym6

I want to know if it is feasible with MVC (assuming we are caching pages).

Perfectly possible with MVC. No doubt on that.

keym6

If not on a single server, how many servers did you need?

It’s purely based on your site’s no of requests. You can achieve it in a single server too. I suggest go with multiple server (if your finance situation allowed :)), it will offer a good back up too (if any one server is failed).

 

keym6

Does anyone have an MVC app running which successfully handles 100-150 pageviews per sec (with output caching)?

That’s our requirement, and I want to know if it is feasible with MVC (assuming we are caching pages). If not on a single server, how many servers did you need?

The subject isn’t as simple as that, you’ll have to do your own performance testing and tuning.  If you can’t tune for the speed you want then you’ll just have to scale out and use multiple servers.  How many?  No-one but you can know as we don’t know what
your site does or how well it is written.  The likes of facebook etc use tens of thousands of servers, don’t kid yourself into thinking it is a site someone has dumped on IIS and given its own app pool.

100-150 page views per sec has almost nothing to do with MVC and everything to do with the infrastructure.  In server parlance they call this the Web Server Farm and use as many servers as they need to get the job done.  I was on a project recently where
the infrastructure alone was over $1 million USD, including Over 60 servers, F5 devices, 6 SQL Servers, and other servers I didn’t understand.  All running Windows and IIS all having load balanacing and clustered db.  I don’t recall their requirements but
obviously they meant buisness.  

Of course there’s always a safe way out of that mess- "The Cloud"

Does anyone know what the maximum cached pageviews/sec asp.Net MVC can serve on a single server (assuming IIs), assuming nothing is user specific in the page so the cached page can be served as is?

Also, does anyone know the max throughput of IIs for raw dynamic pages (without asp.Net/MVC framework)?

Hi keym6,

First, you could cache data in the client (Location.

More information, please refer to:

# OutputCacheAttribute Class

http://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(v=vs.118).aspx

For IIS Output Caching, you could refer to:

# IIS 7.0 Output Caching

http://www.iis.net/learn/manage/managing-performance-settings/walkthrough-iis-output-caching

The maximum cache data, you need to analyze the performance to test it.

There is a link that may benefit you:

# Troubleshooting High CPU in an IIS 7.x Application Pool

http://www.iis.net/learn/troubleshoot/performance-issues/troubleshooting-high-cpu-in-an-iis-7x-application-pool

Best Regards

Starain Chen

[RESOLVED]The extension '.cshtml' doesn't work on subdirectory

cshtml pages don’t work only in a sub-directory of a subdomain. We have a main domain where cshtml works on ‘X’ subdirectory folder, but we have a sub-domain where the root directory is a sub-directory of the main domain and cshtml doesn’t work there. On
IIS, main domain and sub-domain have their own application pool. The ‘X’ sub directory of the main domain has been converted to application and cshtml pages are working. We tried to accomplish the same process, but we have the following error :

This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension ‘.cshtml’ may be incorrect. Please review the URL below and make sure that it is spelled correctly.

Requested URL: /test/test.cshtml

This a simple test file, which works on the main domain sub-directory, but not on the sub-domain sub-directory. I think it is the parent domain that blocks, "it has been explicitly forbidden."

On Handler Mappings the extension is active. (Windows Server 2012 R2, IIS 8.5)

The server has the .NET Framework 4 installed. Also the application is running in an application pool that’s configured to use that version of the.NET Framework.

/home/main_domain/X_subdirectory (works cshtml)

/home/main_domain/sub_domain/subdirectory (doesn’t work cshtml)

Do you have any ideas ?

The following code gives to me an Internal error :

<system.webServer>
   <security>
    <requestFiltering>
       <fileExtensions>
          <remove fileExtension=".cshtml" />
          <add fileExtension=".cshtml" allowed="true" />
       </fileExtensions>
     </requestFiltering>
   </security>
 </system.webServer>

Ref : http://www.asp.net/web-pages/overview/more-resources/aspnet-web-pages-%28razor%29-troubleshooting-guide

Adding this to my web.config doesn’t work neither.

<configuration>
  <appSettings>
    <add key="webpages:Enabled" value="true" />
  </appSettings>
</configuration>

The sub directory where it works is configured as a Web Application :

  1. On IIS manager (Win + R and copy %systemroot%system32inetsrviis.msc)

  2. On the directory in the tree on the left (SitesMain_domainsub_directory

  3. List item Right click on it and I chose "Convert to Application"

If you directly put cshtml in browser it will not work. You need to put your valid URL which you have configured through routing.

When I put directly the cshtml on the browser works for the other subdirectory. It is a simple .cshtml page.

Hi coronadouglass,

According to your description, it works fine if you convert it to the application. So I think it is the independent project and you let it in the main project.

If that is the case, since they are independent, you need to convert it to the application.

Best Regards

Starain Chen

[RESOLVED]There was no endpoint listening at that could accept the message for rest service call

I have created a rest service and hosted it on azure vm’s IIS server.I tested the service with postman rest client,its working fine. I created the client to access the service having proper Address,Binding(webHttp),contract(Shared interface between
service and client). I am able to access the service through mvc webapp using the client when its getting hosted on IIS Express. But when i deployed the same web app package to IIS server its unable to get response from service.it is failing with the error
:There was no endpoint listening at
http://xxx.cloudapp.net:3439/api/yyyService/GetUser?emailId=abc@gmail.com that could accept the message.
This is often caused by an incorrect address or SOAP action

most likely you need to change the server firewall settings. by default the port is blocked.

Hi avisingh,

Thanks for your post.

Check the HTTPERR log  and the Failed Request Trace (FRT) log,please check this:http://blog.leansentry.com/2013/07/the-server-logs-you-need-to-know-to-fix-any-iis-aspnet-error/

And try to  add a port(3439) in Windows Firewall ,please check this:http://windows.microsoft.com/en-in/windows/open-port-windows-firewall#1TC=windows-7

There’s a similar thread:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/bec3ab7a-310e-415f-b538-6d5681e5e53c/there-was-no-endpoint-listening-at

Hope this can be helpful.

Best Regards,

Eileen