Friday, November 26, 2010

ASP.NET MVC 2 Error rised using RenderAction : The controller for path '/' was not found or does not implement IController.

When I try to use RenderAction in ASP.NET MVC2 view:


<%Html.RenderAction("BrowserVersion", "HomeController"); %>


I got the error below:

The controller for path '/' was not found or does not implement IController.



Code for HomeController:


public class HomeController : Controller
{

[ChildActionOnly]
public ActionResult BrowserName()
{
ViewData["BrowserName"] = Request.Browser.Browser;
return View();
}

}

Tuesday, February 23, 2010

MS SQL Server Reporting Services error: The report server has encountered a configuration error

After install of the Sql Server 2005 I got the error:

The report server has encountered a configuration error. See the report server log files for more information. (rsServerConfigurationError)
Access to the path 'C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\RSReportServer.config' is denied.

Thursday, January 21, 2010

How to restore missing controls in Visual Studio 2008 Toolbox

I encountered a problem today when I tried to use Visual Studio 2008.

When I created a Windows forms project, the controls in Toolbox were missing. The usual remedy of right-clicking the Toolbox and then selecting Reset Toolbox did not help.

C:\Documents and Settings\[User Name]\Local Settings\Application Data\Microsoft\VisualStudio\9.0

Monday, December 7, 2009

How to generate a transparent GIF image using C#

There is apparently no easy way to generate a transparent GIF image using the .NET framework. Microsoft provided a method in the Bitmap class called MakeTransparent() but it doesn’t work for GIFs, it only seems to work for PNGs.

To create a transparent GIF you need to recreate the color table of the image using Imaging APIs. Unfortunately, this can be pretty slow for an ASP.NET Web application, and it has a lot of overhead, so I needed an alternative.

Solution:

The alternative is to alter the color table directly using the GIF specification. To implement this, I needed to save the non-transparent GIF to a MemoryStream, and then go through the binary data, updating the color table with the new transparency bits.

Wednesday, October 28, 2009

How to increase sound level using C#

To increase sound level using C# first of all you should add line:

using System.Runtime.InteropServices;

to allow using COM Interop in your class.

Next we derlare two functions from an unmanaged DLL:

Friday, October 23, 2009

Capture Sound and save into wav or mp3 file .NET C# example

It's surprising that there are no components for sound capturing in .NET Framework 3.5. Even designers of WPF and Silverlight 2.0 were focused on graphics so deeply, that they forgot about applications recording sound from user's microphone. It is said that the next version of Silverlight will provide such functionality.

However, what you often want to achieve is to store the recorded sound in MP3 file (or send it as MP3 stream). That's legally complicated due to MP3 patent constraints. And for the same legal reason, we can assume that we will not see MP3 functionality in Microsoft technologies soon (there is WMA instead).

Wednesday, July 29, 2009

How to get data from Firebird database using MS SQL Server stored procedure

In solving one of the tasks (рассчет автокредита) I needed an opportunity to perform stored procedure of SQL Server 2005, to receive data from the FireBird database.

Typically stored procedure in T-SQL can not do this, so I wrote a stored procedure in C#, which receives the necessary data to the DataTable(s), from where then method SqlContext.Pipe.SendResultsRow, passing a string SQL Server.
Here is the example:

Wednesday, May 6, 2009

How to connect to SQL Server 2008 using 2005

While supporting the website калькулятор на автокредит I encountered a problem when I use SQL Server Management Studio in SQL Server 2005 to connect to an instance of SQL Server 2008.
To solve this problem, I installed Microsoft SQL Server 2005 Service Pack 2. After that I also installed "Cumulative update package 12 for SQL Server 2005 Service Pack 2 (server and client)".
And, voila, it works!

Tuesday, April 28, 2009

How to sort the hierarchical recursive query in SQL Server 2005

In SQL Server 2005 was an innovation in the form of CTE (common table expressions), which enables the hierarchical recursive queries to the database. While designing the web site автокредит на автомобиль I have a challenge: to display the hierarchical structure of pages of the site. The query also have to sort sort the data on a field "pageorder" from the pages with the same level of hierarchy.

The structure of the table looks like this:


CREATE TABLE [dbo].[pages](
[id] [int] NULL,
[pid] [int] NULL,
[title] [nvarchar](max) NULL,
[pageorder] [int] NULL
) ON [PRIMARY]


The field "pid" points to id of the parent record. In addition, there have to exist a root(entry) record, whose pid = NULL.

Below is a sample request that selects and sorts the hierarchical data:

Wednesday, March 25, 2009

How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?

How to disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest in .NET Framework in C#?
По умолчанию, при выполнении веб-запроса, используя класс HttpWebRequest, .NET Framework добавляет HTTP заголовок (HTTP header) "Expect: 100-continue". Для того, чтобы запретить формирование этого заголовка нужно сделать следующее:

As default when You use HttpWebRequest class to execute web-requests it appends HTTP header "Expect: 100-continue" to it's headers collection. To disable passing of HTTP header "Expect: 100-continue" using HttpWebRequest You can do following:

How to place DateTimePicker onto ToolStrip control in Windows Forms .NET application?

To place DateTimePicker onto ToolStrip control in Windows Forms .NET application you had to do following:

DateTimePicker dateTimePcr = new DateTimePicker();
toolStrip1.Items.Add(new ToolStripControlHost(dateTimePcr));

Tuesday, March 3, 2009

How to enabling Gzip and Deflate HTTP Compression in ASP.NET pages

If your ASP.NET web application doesn't already contain a Global.asax file, create a new one using notepad. Then insert following code in it:


<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.IO.Compression" %>