Fix Upload_Max_Filesize for WordPress on Windows Hosting

upload-icon-20606

 

I needed to upload a file on a WordPress website, and the following issue was showing up:

The uploaded file exceeds the upload_max_filesize directive in php.ini

 

All the solutions I found show how to update the php.ini file, but this only works on Linux Hosting. For Windows Server and Windows Hosting accounts, you need to follow the next steps to solve the issue: Continue reading

Fixing AngularJS + MVC Routing Issues

hashratestore_icon-1Currently, I’m working on a hybrid AngularJS and MVC project, one of the tasks being to get rid of the # symbol from the URL. In pure AngularJS apps, this is very easily done by following the next two steps (and easily googled):

  1. Set up your base href in your index page: <head> <base href=”/”> </head>
  2. Add the following in your angular app config: $locationProvider.html5Mode(true)

 

The problem arises when you are in the .NET stack and using AngularJS with MVC. The above solution will still remove the # from URL, but page refresh won’t work. Why? This happens because MVC knows nothing about AngularJS routing and by following default MVC routing, it will look for an MVC page which doesn’t exist. Continue reading

Convert Enum to KeyValuePair List and remove unwanted Enum options #Linq

In our new project, using Angular, I needed to fill drop down lists in a form from a set of enums. One particular case was to set the below Status Enum as a drop down list.

    public enum Status
    {
        Deactive = 1,
        Active = 2,
        Expired = 3,
        Deleted = 4,
    }

To do that, the best solution I found was to convert the enums to a list KeyValuePair items. How do you do that? Continue reading

Create iOS and Android apps using Visual Studio and .NET

IC764760

Microsoft today announced some amazing news:

First the big news. Microsoft just launched the preview versions of Visual Studio 2015 and .NET 2015. This release includes the “Roslyn” .NET compiler platform, new language features in C#, improved debugging and profiling, and code analysis tools. And the biggest new of all – VS2015 supports “C#, C++ and HTML/JavaScript development targeting iOS, Android, Windows and more.” There’s even a Visual Studio Emulator for Android (see picture below).  I’m drooling! Continue reading

How to open a razor link in a new tab – Quickie

link-new-tab

An MVC code quickie to open a Razor link in a new tab:

RunReport”, “Performance”, new { reportView = Model.ReportView.ToString() })”
type=”submit”
id=”runReport”
target=”_blank”
class=”button Secondary”>
@Reports.RunReport
</a>

Hope this helps 😉

Xaml – Add and Update Row Definitions

XAML-LOGO Row and Column Definitions are used to set the rows and columns in a grid on a xaml page. I wanted to add or remove any of these definitions from the code behind using C#. Next is the solution:

Add Row Definitions:

RowDefinitionCollection defs = myGrid.RowDefinitions;
defs.Add(newRowDefinition(){Height=newGridLength(140)});
defs.Add(newRowDefinition(){Height=newGridLength(1,GridUnitType.Star)});

Update Row Definitions:

RowDefinitionCollection defs = myGrid.RowDefinitions;
defs[0] = newRowDefinition(){Height=newGridLength(140)};
defs[1] = newRowDefinition(){Height=newGridLength(1,GridUnitType.Star)};

 

To add and update columns, just change RowDefinition with ColumnDefinition in the above code. Hope this helps you in your Windows Phone and Windows Store apps! Happy Xamling!

MVC ActionLink not working after submit

These past days, I was having a problem with links for an iPad web app. The problem was that when I submit a form (step 1) and go to the next form (step 2), the link to return back to step 1 was not working. Apparently the problem is caused by Ajax. The solution is the following, instead of using the normal form tag to init a form:

      ……

use this type of form initialiser

@using (Html.BeginForm(“action”, “controller”, FormMethod.Post))
{

      ……

}

And add the following attribute:

{ “data-ajax”, “false” }

So the final code would look like this:

@using (Html.BeginForm(“action”, “controller”, FormMethod.Post, new Dictionary { { “data-ajax”, “false” } }))
{
……

}

Hope this post helps you, and reduces your swearing 🙂 Happy Form-ing!

 

 

 

Delete Operation in MVC

This week I just started some MVC tutorials which I’m really liking. And after some tutorials I found this “Performing a delete operation in response to a GET request (or  for that matter, performing an edit operation, create operation, or any other  operation that changes data) opens up a security hole”.

The problem is that if you create a link with the following href: www.mydomain.com/Movies/Delete/23, it will delete the movie with the passed id 23. If a hacker finds this, he can create a loop and delete all of your movies in the database.

The best solution would be to delete an item in an HTTP POST operation instead of the get, so the user must submit a form to delete an item. This is done using either buttons, or else images using the following markup:

                <% using (Html.BeginForm("Delete", "Home", new { id = item.Id }))
                   { %>
                    <input type="image" src="Content/Delete.png" />
                <% } %>

This will create an image link in a form which would POST the delete operation. This will reduce the security hole in your system. I suggest you read this article by Stephen Walter. Hope this will help you in your new MVC adventures.

 

 

CSS Tricks Quickie – Multiple Border Styles and Radius

Did you know that you can set multiple border styles for the sides of divs and images. By using the following css script, you can define any multiple borders you want:

div
{
border-width:5px;
border-style:dotted solid;
}

By using this with another css trick, the border radius, you can set some nice effects when hovering images. The radius css is below (all three must be include to work in all browsers):

-moz-border-radius:13px;
-webkit-border-radius:13px;
border-radius:13px;

Do you have some more simple tricks? Let me know in the comments 😉 Happy CSSing!

Resources

Format Date in SQL Server

It’s very common to show the current date (i.e., month, day, and year) in different formats. Although you can obtain the current date with Microsoft SQL Server’s GETDATE function, getting the returned date in the format you need can take a lot of effort and code. The FormatDate UDF (user-defined function) provides dates in various formats by using the following options: Continue reading