BeetleDev.com
info
contact
Tuesday, September 17, 2019
Beetle Blog
1
By: douglas - ASP.net - 4/14/2013 12:58:34 AM

Following this tutorial:

http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
 
Using:
WebMatrix 2 or 3 (This will also work with VS.net 2010, 2012 using the WebPages framework)
NuGet
 
Open WebMatrix
 
Create a new WebPages site.
 
Using NuGet install the Microsoft ASP.NET SignalR package: Microsoft.AspNet.SignalR
 
If you are installing from scratch make sure to install the entire package which is exactly Microsoft.AspNet.SignalR, not just the Core or other libraries.
 
It will install a bunch of JavaScript files and place the SignalR libraries (dlls) in your Bin folder.
 
Create an App_Code folder.
 
Create a C# class called ChatHub.cs in the folder.
 
Replace the contents with the following code:
 
using System;
using System.Web;
using Microsoft.AspNet.SignalR;
 
namespace SignalRChat
{
    public class ChatHub : Hub
    {
        public void Send(string name, string message)
        {
            // Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);
        }
    }
}
 
Create an _AppStart.cshtml at the root of your site.
 
Add the following code to _AppStart.cshtml:
 
@using System.Web.Routing;
@using Microsoft.AspNet.SignalR;
 
@{
    // Register the default hubs route: ~/signalr/hubs
    RouteTable.Routes.MapHubs();
}
 
Add a new HTML page to your site.  For example: chat.html
 
Replace the contents with the html from the tutorial.
 
Take a look at the references to your .js libraries and make sure that they match what you have in the /Scripts directory. If not update the references.
 
If the jQuery you have is older than the one referenced then update your jQuery libraries to at least the one referenced.
 
Now run the site and go to your chat.html page.  You should get prompted to enter your name and then be able to submit messages to the app.
 
Open additional tabs or browser windows, browse to the same page and you should be able to see messages typed in other windows get sent to all other open windows.
 

By: douglas - ASP.net - 8/24/2010 1:10:44 AM

 Issue:

Your asp.net application uses the membership and roles provider and users have checked the "remember me" option when logging in that uses a persistent cookie to keep a user logged in.  If the app pool for an asp.net application is recycled the user may become logged out even though the cookie has not expired and still exists.

This issue most often appears in a web farm but can appear in a single server environment.

Cause:

The cookie becomes invalid because the machine key for the application has changed after the app pool recycles.  The machine key is used to read the persistent cookie.  Since it has changed your application can no longer read the cookie and users appear to be logged out.

Solution:

Add a static segment to the web.config.  This will make your application use the same machine key even after an app pool recycle.

Additional Information:

About Machine Key:

http://msdn.microsoft.com/en-us/library/ms998288.aspx#paght000007_machinekeyexplained

Tool for generating a Machine Key for the web.config:

http://aspnetresources.com/tools/machineKey

 


By: douglas - ASP.net - 4/10/2009 9:41:59 PM

After installing ASP.net MVC v1 it is supposed to install the ASP.net MVC project template into VWD2008.

If it does not, make sure you have VWD2008 sp1 and then go to "Tools" > "Import and Export Settings..." and reset the VWD settings.

Now you should be able to create ASP.net MVC projects in VWD2008.


By: douglas - ASP.net - 8/7/2008 1:15:13 AM

When you use a LinqDataSource as the datasource for a GridView you may run into an issue if you try to display data from a child object/table in the LinqDataSource.

For example if you have an object Order and child object Customer trying to call Customer.FirstName will be blank.  This is a bug in .net 3.5.

If you set EnableDelete, EnableInsert or EnableUpdate on the LinqDataSource the Eval statement will work.

Other workarounds and details can be found here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2995461&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2469812&SiteID=1


By: douglas - ASP.net - 5/28/2008 3:16:14 PM

This seems to be an error in the ASP.net runtime.

It can happen with MasterPages or UserControls.  Often it will happen after you update a file and place it on the server.   ASP.net is not able to always compile properly.

There is a hotfix from Microsoft for this.

http://support.microsoft.com/kb/915782

There is a workaround for this issue:

<configuration>

   
<system.web>
       
<compilation debug="false" batch="false"></compilation>
   
</system.web>

</configuration>


When you have an SqlDataSource that has a SelectCommand and Select parameters.  If the select parameters are optional or null the datasource will not return any records.

This may occur when using a stored procedure.  Testing the datasource in visual studio returns records and testing the stored procedure will also return records.  However the datasource and datagrid it binds to does not return any records.

The issue may be caused by a property in the SqlDataSource: CancelSelectOnNullParameter.  This property is defaulted to true and will prevent the select command from running if select parameters are null.

Set CancelSelectOnNullParameter="false"



By: douglas - ASP.net - 12/29/2007 12:23:55 AM

Here is how to start the standalone server that comes with VS.net 2005 and higher from the command line:

Start /B C:\WINDOWS\Microsoft.NET

\Framework\v2.0.50727\WebDev.WebServer.exe /port:1234 /path:"C:\YourWebSitePath"
 
If you place this line in a bat file you can start your web server by running the bat file.
 
WebDev.WebServer.exe is the web server.
 
 
 

By: douglas - ASP.net - 4/8/2007 3:29:13 PM
When using the PopupControl extender, if you run into an issue where the popup control does not pop up in the correct position when the page is scrolled you should make sure you have these HTML elements on your page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

By: douglas - ASP.net - 10/18/2006 1:23:27 AM
By default the ASP.net upload control is limited to around a 2 MB upload.  Trying to upload larger files result in an error.

To set the upload capacity of the upload control place these tags in the web.config:

<httpRuntime maxRequestLength="655350" useFullyQualifiedRedirectUrl="true" executionTimeout="600" />

Or:

<httpRuntime

executionTimeout="90"

maxRequestLength="4096"

useFullyQualifiedRedirectUrl="false"

minFreeThreads="8"

minLocalRequestFreeThreads="4"

appRequestQueueLimit="100"

/>


By: douglas - ASP.net - 9/24/2005 2:20:48 PM

These are good articles that show how to implement event bubbling with ASP.net.  Event bubbling is where an event in a user control can be handled by the parent page/control or another control.

http://authors.aspalliance.com/tempest/bubble.aspx

http://odetocode.com/Articles/94.aspx


Here is a good article show how to implement forms authentication and role based security using a database.

http://www.eggheadcafe.com/articles/20020906.asp


By: douglas - ASP.net - 8/7/2003 7:09:00 PM

System.IndexOutOfRangeException: <FieldName>

This error usually means that your query did not include <FieldName> so the code cannot find it.


By: douglas - ASP.net - 7/30/2003 6:28:00 PM

Add shift jis to meta tag
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">

Add globalization to the web.config

 <system.web>
<globalization
fileEncoding="shift_jis"
requestEncoding="shift_jis"
responseEncoding="shift_jis"
/>
</system.web>

If using DreamweaverMX, go to "Page Properties" and choose shift jis as the encoding for the page.

In VS.net 2005 go to "File" - "Advanced Save Options...".  Then choose "Unicode (UTF-8 with signature) - Codepage 65001".  It seems that if you choose shift-jis as the save settings (or Western European), when you open the page again the Japanese characters will be messed up.  But if you save as Unicode you can open the file with the Japanese characters intact.  This seems to work for ascx files too.

Update:
Found out that if you use these settings and do not use any meta tags Japanese characters seem to work ok on the page, forms and in the database.  Also be sure that the ASP.net page directive does not specify an responseEncoding.

<system.web>
    <globalization
            fileEncoding="utf-8"
            requestEncoding="utf-8"
            responseEncoding="utf-8"
   />  
</system.web>

You can change responseEncoding to shift_jis if your pages will only be using Japanese.

ใƒ†ใ‚นใƒˆ


By: douglas - ASP.net - 7/18/2003 6:33:00 PM

When working with web forms and validation. Always make sure to check that the page is valid before performing any operations.

Possible Symptoms:

  • Custom controls not firing
  • The page exhibits unexpected behaviors

Even if you have validation controls on a page, if you do not check that the page is valid, your functions will still execute.

Use: Page.IsValid to check if the page is valid.




By: douglas - ASP.net - 8/9/2002 12:00:00 AM

Web services are used to exchange data between different systems via standard Internet protocols. This tech note describes the process of creating a simple web service and how to use WSDL to create a web service proxy class as it pertains to ASP.net.

When creating a web service, you may need to complete the following steps:
  1. Create the .asmx file
  2. Publish the .asmx file
  3. Use the command line wsdl tool to create a source file based on the .asmx file
  4. Compile the resulting source into a library
  5. Place the dll in the bin directory
  6. Create an aspx file that uses the dll to consume the web service

Creating a code file to be compiled into a web service proxy class:

Using a file to generate the code:
wsdl.exe /l:CS /n:MathService /out:MathService.cs MathService.wsdl

Using a URL to generate the code:
wsdl.exe /l:CS /n:MathService http://www.webserviceurl.com/webservices/webservice.asmx?WSDL

/n:MathService specifies the namespace you want this service to have. This is what you use in the import directive of your aspx file once the code is compiled as a dll and placed in the bin directory.

1

Beetle Blog v0.2.2


Copyright © 1997 - 2019 BeetleDev.com. All rights reserved.