Thursday, August 7, 2014

How to link to a root controller from area controller in MVC

Sometimes you need to call a root controller from inside of an area, usually when you are inside of an Admin console for example.
The process is really simple, all you have to do is specify the area as blank in the RenderAction or the RedirectToAction functions.



        <% Html.RenderAction("Action", "Controller", new { area = "" }); %>


        public ActionResult redirect()
        {
            return RedirectToAction("Action", "Controller", new { area = "" });

            return RedirectToAction("Action", "Controller", new { area = "", id = 5 });

        }


Wednesday, August 6, 2014

IIS An application with this virtual path already exist

If you get the the error "An application with this virtual path already exist": 


when creating an application in IIS is because an application was previously created pointing to that path, some people get confuse because they don't see the application in the connections panel, to remove the virtual path follow the next steps in IIS.

Open IIS Manager

In the Connections pane, expand the Sites node, then click to select the site in which the application is running



In the Actions pane, click View Applications




On the Applications , select the application you want to remove, then click Remove link in the Actions pane.



Click Yes to confirm that you want to remove the application.
Now you are going to be able to create your application!

Get the size of the tables in SQL

With the next query you can get the size of all the tables in a database.
  
--
-- This query will return the information of the tables
--

SELECT 
    t.NAME AS table_name,
    s.Name AS [schema_name],
    p.rows AS row_count,
    SUM(a.total_pages) * 8 AS space_KB, 
    SUM(a.used_pages) * 8 AS used_space_KB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS unused_space_KB
FROM 
    sys.tables t
    INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
    INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
    INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
    LEFT OUTER JOIN 
    sys.schemas s ON t.schema_id = s.schema_id
WHERE 
    t.NAME NOT LIKE 'dt%' AND 
 t.is_ms_shipped = 0   AND 
 i.OBJECT_ID > 255 
GROUP BY 
    t.Name, s.Name, p.Rows
ORDER BY 
    t.table_name DESC