Tags: | Categories: Deutsch Posted by AlexanderZeitler on 2/4/2012 1:37 PM | Comments (0)

In Single Page Applications verwendet man häufig Hash-Bang Urls (was das ist, hat Robert hier beschrieben).

Setzt man nun anstelle des üblichen HomeControllers, der die Startseite (üblicherweise die Index View) rendert, eine statische default.htm Datei ein, will man natürlich die Hash-Bang Urls möglichst elegant und wie z.B. von twitter gewohnt in diesem Stil darstellen:

http://meineseite/#!/machwas

Durch die Verwendung der default.htm mit aktiviertem Default-Controller, müßte man das ganze allerdings so darstellen:

http://meineseite/default.htm#!/machwas

Leider funktioniert

http://meineseite/#!/machwas

zunächst nicht mehr (es erscheint die Index-Seite des HomeControllers oder ein 404, falls man den HomeController bereits gelöscht hat).

Der Grund liegt in den Route-Definitionen, die per Default in der Global.asax.cs definiert sind, genauer in der Definition eines Default-Controllers:

Entfernt man die Definition des Default Controllers

funktioniert der Aufruf von

http://meineseite/#!/machwas

wie gewünscht.

Natürlich kann man auch die Index-View des HomeControllers als Startseite für eine Single Page Application verwenden, was ich persönlich aber nicht (mehr) mache.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , | Categories: Deutsch Posted by AlexanderZeitler on 1/23/2012 4:08 PM | Comments (0)

.NET Usergroup Karlsruhe Logo

Am 26.01.2012 um 18:00 Uhr findet das nächste Treffen der .NET Usergroup Karlsruhe (XING-Gruppe der .NET Usergroup Karlsruhe) statt.

Thema

Know your Tools

Details zum Thema

Alternativen zu den klassischen Tools
Im Zentrum steht natürlich VisualStudio 2010

  • was bringt VS 2012?
  • welche Alternativen gibt es ?
  • Add-Ons, die im Allgemeinen verwendet werden
  • Zielplattformen, die mit .NET bedient werden können (WP7, iPhone, Android, Metro, Linux, OSX)
  • UI-Technologien und Tools (WPF, Silverlight, Metro, GTK, Android, ...)
  • Offene Diskussion, es besteht auch die Möglichkeit ,dass jeder seine Tools vorstellen kann

Über den Sprecher

Frank Pfattheicher, Alexander Zeiter und möglichst viele aus der Usergroup Winking smile

Teilnahme

Bitte meldet Euch wieder via XING an, die Location ist wieder DJK-Ost:

DJK-Ost
Friedrichstaler Allee 52
76131 Karlsruhe

Anfahrt: http://www.djk-ost.de/html/vereinsheim.html

Currently rated 1.5 by 2 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , | Categories: Deutsch Posted by AlexanderZeitler on 12/28/2011 3:31 PM | Comments (0)

Auf dem 28th Chaos Communication Congress (28C3) wurde eine Sicherheitslücke veröffentlicht, die neben anderen Plattformen auch ASP.NET betrifft.

Betroffen sind ASP.NET-Seiten, die application/x-www-form-urlencoded oder multipart/form-data verarbeiten.

Weitere Details gibts im Blog-Post des Security Research & Defense Blogs von Microsoft.

Microsoft arbeitet bereits mit Hochdruck an einem Fix, der evtl. sogar außerhalb des monatlichen Update-Zyklus’ verteilt werden soll.

Currently rated 2.6 by 7 people

  • Currently 2.571429/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , | Posted by AlexanderZeitler on 12/26/2011 8:16 PM | Comments (0)

When applying bindings in knockoutjs explicitely to a specific DOM element, you may get this error:

Uncaught Error: ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node

Your HTML might look like this:

...and your Javascript like this:

Whats wrong with it? Let's try document.getElementById instead:

Now everything works as expected:

correct list

So what’s wrong with the jQuery way of selecting the DOM element?

When using var menu = $("#menu") we don’t get a DOM object but a jQuery object instead.

To get the correct DOM element, we have to use one of the ladder two of the following (first one is for understanding purposes only):

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , | Posted by AlexanderZeitler on 12/11/2011 12:05 AM | Comments (0)

If you’re deploying a WCF Web API application to your IIS 7.x you might receive a HTTP Error 404.0 (MapRequestHandler / StaticFile):

404

As you know, WCF Web API relies on .NET Framework 4.0.

So lets take a look into the application pool for our application:

.NET Framework 4.0 selected

Everything looks fine here.

So lets dig a little bit deeper – namely inspect the ISAPI Filters:

IIS Manager / choose ISAPI Filters

IIS Manager / ISAPI Filters ... ASP.NET 4. is missing

Looks like ASP.NET 4 is missing here… so lets fix it:

PS C:\Windows\Microsoft.NET\Framework64\v4.0.30319> .\aspnet_regiis.exe -i
Start installing ASP.NET (4.0.30319).
........
Finished installing ASP.NET (4.0.30319).

Now hit F5 in your browser:

yay!

(If it’s not working after installing ASP.NET 4.0.x please review the version in your application pools settings again and fix it if necessary).

Currently rated 2.6 by 7 people

  • Currently 2.571429/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted by AlexanderZeitler on 12/6/2011 6:42 PM | Comments (0)

Wenn

git flow init

den Fehler

flags: FATAL unable to determine getopt version

unter Cygwin liefert, einfach das Package

util-linux

nachinstallieren.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , | Posted by AlexanderZeitler on 12/6/2011 6:33 PM | Comments (0)

Wenn man die Fehlermeldung

$'\r': command not found

nach dem Aufruf von

git flow init

unter Cygwin erhält, liegt das an den Windows codierten Line-Endings der git-flow-Dateien unter

C:\Cygwin\usr\local\bin

Einfach mit einem Editor (z.B. Notepad++) der Wahl auf UNIX umstellen.

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , | Posted by AlexanderZeitler on 11/15/2011 3:11 PM | Comments (0)

With WCF Web API there has been introduced some new stuff called JsonValue and JsonArray.

If you want to POST some JSON to your Web API method like this without having some corresponding .NET objects on the server side:

You can easily parse it using JsonValue and JsonArray:

Or the "prettified" version:

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , | Categories: Deutsch Posted by AlexanderZeitler on 11/7/2011 12:15 PM | Comments (2)

Robert hat vor kurzem “Keep it simple! YAGNI!” mit Bezug auf das Posting “Keep your code simple!” von Daniel Lang gepostet.

Da ich immer mal wieder gefragt wurde, wie man die NHibernate ISession in ASP.NET MVC per Request verwenden kann, hier ein Auszug aus der Global.asax:

public static void RegisterRoutes(RouteCollection routes) {
	routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

	routes.MapRoute(
		"Default", // Route name
		"{controller}/{action}/{id}", // URL with parameters
		new {controller = "Home", action = "Index", id = UrlParameter.Optional}
		);


	ControllerBuilder.Current.SetControllerFactory(
		new LightCore.Integration.Web.Mvc.ControllerFactory(_container));
}

protected void Application_Start() {
	AreaRegistration.RegisterAllAreas();
	setupIoC();
	RegisterGlobalFilters(GlobalFilters.Filters);
	RegisterRoutes(RouteTable.Routes);
}

void setupIoC() {
	Action<MappingConfiguration> mappingsConfig =
		mappings => mappings.FluentMappings.AddFromAssemblyOf<ContactMap>();
	
	var builder = new ContainerBuilder();

	SessionFactory =
		Fluently.Configure().Database(
			MsSqlConfiguration.MsSql2005
				.ConnectionString(
					connectionString => connectionString
						.FromConnectionStringWithKey("MvcNHibernate")))
						.CurrentSessionContext("web") // für ISession per Request
				.Mappings(mappingsConfig).BuildSessionFactory();

	builder.Register<ISession>(c => SessionFactory.GetCurrentSession());

	var container = builder.Build();
}

protected void Application_BeginRequest() {
	CurrentSessionContext.Bind(SessionFactory.OpenSession());
}

protected void Application_EndRequest() {
	CurrentSessionContext.Unbind(SessionFactory);
}

public static ISessionFactory SessionFactory { get; private set; }

Zunächst werden die Mappings gelesen und mittels FluentNHibernate eine SessionFactory erzeugt. Diese wird als Property verfügbar gemacht und in Application_BeginRequest wird eine ISession erzeugt bzw. Application_EndRequest zerstört.

Wenn die ISession innerhalb des Requests (z.B. in einem Controller) benötigt wird, wird sie per IoC-Container (in diesem Fall LightCore) von der SessionFactory angefordert und bereitgestellt.

Der Controller sieht dann wie folgt aus:

public class HomeController : Controller {
	readonly ISession _session;

	public HomeController(ISession session) {
		_session = session;
	}

	public ActionResult Index() {
		ViewBag.Message = "Welcome to ASP.NET MVC!";
		var customers = _session.Query<Customer>();
		return View(customers);
	}

	public ActionResult About() {
		var contacts =_session.Query<Contact>();
		return View(contacts);
	}
}
DotNetKicks-DE Image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: | Categories: Visual Studio 2010 Posted by AlexanderZeitler on 11/4/2011 11:25 PM | Comments (0)

Some of you may have encountered the following problem:

Especially in ASP.NET MVC 3 projects (but not only) your Visual Studio may stop responding to your keyboard – mostly backspace and arrow keys (add others if you like <sarcasm/>).

The only solution seems to be a restart of Visual Studio.

But there’s a simple workaround: hit Ctrl+Tab twice which brings you to the previous file you have been editing and then back to the file you wanted to edit ultimately – and everything should be fine.

DotNetKicks-DE Image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5