Category Archives: asp.net-mvc

asp.net mvc on ubuntu 16.04 apache2 server

I made a website in Visual Studio 2015 using ASP.NET MVC and I am trying to move it from my dev environment to my web hoster. My website is hosted on an ubuntu server 16.04 using apache2. I have researched and found sites that told me to use MonoMod to be able to run ASP.NET MVC and it still has yet to work and after many hours of researching I have decided to throw in the towel and come to you, the Stack Overflow Community! Thank you in advanced to anyone who helps!

Apache2 ASP MVC Razor view crashes when referencing PCL enum for dropdown

I am new to using ASP.net on ubuntu with mono, I have several websites working very well indeed using MVC5, though I recently migrated a project over and have found that forms referencing enums from a referenced PCL cause views to crash. Below is my EnumDropDownList call which works fine on a windows host.

<div class="form-group">
@Html.LabelFor(m => m.Type, new { @class = "control-label" })
@Html.EnumDropDownListFor(m => m.Type, new { @class = "form-control" })
</div>

When viewing this in the browser on the ubuntu host however I get the following error

System.InvalidOperationException
The view found at '~/Views/portal/productgroup.cshtml' was not created.

Additional the stack trace is

     at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00061] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00080] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <cc73190bab9d435c831510ff295c572a>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (System.Collections.Generic.IList`1[T] filters, System.Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0004f] in <cc73190bab9d435c831510ff295c572a>:0 

Is there a way I need to reference the external assembly in my controller or my razor view? Is this a common issue or could there be something specific going on?

For reference the PCL holds some shared code for use between my site and a mobile app built using Xamarin. The PCL has the profile .NET framework 4.5 in addition to all of the Xamarin ones etc. The code is fully operational on windows and will work if I remove references to the enum stored in the PCL.

Any help would be greatly appreciated.

PHP Curl repeats request if the IIS server hits a breakpoint

I have a ASP MVC site which is a very basic REST service protected by a HMAC authentication scheme. At the moment it is failing to authenticate using a PHP client library.

In order to try to debug this, I run the site from visual studio, use a linux VM to work on the php side of things and expose my IIS site to that VM.

As soon as I set a breakpoint in the ASP site on the authentication filter, I saw that breakpoint being hit multiple times for what I thought was a single php curl request. I fired up fiddler and it actually seems if I hit a breakpoint on the ASP side, the curl request seems to replay itself over and over, interestingly even the HMAC stuff seems to be recalculated which infers the php script is being executed multiple times. The rate seems overly excessive as well, approx 20 per second.

If I remove that breakpoint, only one curl request gets sent.

Having that many requests hit the server when you are trying to debug an async authentication method really does make life hard.

I saw the headers had a Connection: Keep-Alive on it so I tried removing that from the curl parameters, but that didn't help

Anyone got any ideas please?

C# website with Apache server

I've got this scenario: I want to build a website to a friend só he can manager his business. I want to do it like it is going to be online, using C# MVC. The thing is that only my friend will use the system, on localhost:/something...

My question is: if I put the files of my app on Apache, installed in my friends computer, will he be able to access the web site thru localhost:/mysite...?

asp mvc htaccess is not working (redirect without changing url)

I have two ASP.NET project version of my website under same domain. New beta version is uploaded to a sub-folder.

Old path: domain.com/v1/default.aspx (which is already redirected to domain.com)

New path: domain.com/v1/v2 (which is redirected to domain.com/v2 by window.location method used on domain.com/v1/default.aspx)

I tried to redirect using .htaccess but the .htaccess file itself is not working at all.

So In a nutshell my problem is, How can I redirect/rewrite "domain.com/v1/v2/" to "domain.com" without using .htaccess file.

IIS url rewrite ignores .chtml ( Razor ) files

I have a rewrite rule that says.

site.one/content/templates/whatever.cshtml -> site.two/content/templates/whatever.cshtml

The problem occurs when site.one trying to fetch .cshtml files. It returns a 404. However if i change the extension to .js or .html then the rule works.

If i use the site.two link the request handles it just fine, this is without any rewriterules ofcourse. site.one can also handle .cshtml files from within its own directory.

Iam using IIS 10, Urlrewrite module 2, and Application Request Routing 3.

UPDATE

So the .cshtml in this case are template files that is fetched with async text.js, and then gets compiled with handlebars as the last step before rendered, but some of them need to get processed by razor engine because of the translations. This works if not rewriting.

How to publish asp.net mvc web application to apache2 mod mono

I have a machine which runs Ubuntu 14.04 server with Apache2. I would like to run an asp.net mvc web application created with MS Visual Studio 2013. I figured out I need the mod_mono module on apache, but afterwards I am a bit stuck. How can I deploy and run my asp.net mvc web app? I tried publishing to folder in Visual Studio, I get the folders and files, but I do not know how to run it on my Apache2 web server. Can somebody help me out? Or can you redirect me to a step by step tutorial?

tnx Carl

How to measure outgoing traffic size in postgres+apache

Postgres 9.1 is hosted in virtual server in Internet provider. Internet provider limits traffic to 1 TB per month. Debian Sqeeze x64 is used running Postgres, Apache and Mono MVC4 with mod_mono. Incoming traffic is coming to 80, 443 and 5432 ports.

How to get report about outgoing traffic by ip addresses in current month. Output should contain 2 columns:

  1. ip address of incoming connection
  2. Total amount of traffic in current month

for IP addresses having most traffic.

Apache access_log contains bytes transfrerred. Howerer postgres log_line_prefix doesnt allow to specify number of bytes transferred logging. How to log this ?