PDA

View Full Version : سوال: مشکل routing در mvc3



ahmad_lashgari
سه شنبه 17 آبان 1390, 10:03 صبح
سلام دوستان،
من توی routing به یک مشکل برخوردم :
من دو تا کنترلر دارم (Home و Portfolio) توی کنترلر home چند تا action دارم (Contact,feedback...) می خوام برای نمایش این action ها نام کنترلر Home نمایش داده نشود. هر کاری می کنم تداخل داره :ناراحت:
ممنون میشم اگر کمکم کنید.

amir-yeketaz
سه شنبه 17 آبان 1390, 22:58 عصر
سلام دوست عزیز ...

داخل فابل Global.asax , داخل متد RegisterRoutes اینو نوشتم و مشکلی وجود نداشت :

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

ahmad_lashgari
یک شنبه 22 آبان 1390, 10:28 صبح
ممنونم دوست عزیز

ERIKA
دوشنبه 23 آبان 1390, 14:58 عصر
سلام در مورد این ادرس دهی یک سوالی داشتم
میخاستم ببینم چطوری میتونیم فضا های خالی و کاراکتر های خاص را از ادرس بار یا عننوان مان حذف کرده و یا با یک کاراکتر دیگه ای جایگزین کنیم

ERIKA
پنج شنبه 26 آبان 1390, 18:09 عصر
من یک همچین تیکه کدی هم توی vb براش دارم حالا میخام همین را توی MVCپیاده اش کنم ولی نمیدانم چچطور باید این کار بکنم



PublicSharedFunction removeSpaceAndSpesialChar(ByVal strTitle AsObject) AsString
If (IsDBNull(strTitle)) Then
strTitle = "بدون عنوان"
EndIf
If (strTitle.ToString.Length = 0) Then
strTitle = "بدون عنوان"
EndIf
strTitle = strTitle.Trim()
strTitle = Regex.Replace(strTitle, "<(.|\n)*?>", String.Empty)
'Trim "-" Hyphen
strTitle = strTitle.Trim("-"c)
strTitle = strTitle.ToLower()
Dim chars AsChar() = "$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray()
strTitle = strTitle.Replace("C#‎‎", "C-Sharp")
strTitle = strTitle.Replace("vb.net", "VB-Net")
strTitle = strTitle.Replace("asp.net", "Asp-Net")
'Replace . with - hyphen
strTitle = strTitle.Replace(".", "-")
'Replace Special-Characters
For i AsInteger = 0 To chars.Length - 1
Dim strChar AsString = chars.GetValue(i).ToString()
If strTitle.Contains(strChar) Then
strTitle = strTitle.Replace(strChar, String.Empty)
EndIf
Next
'Replace all spaces with one "-" hyphen
strTitle = strTitle.Replace(" ", "-")
'Replace multiple "-" hyphen with single "-" hyphen.
strTitle = strTitle.Replace("--", "-")
strTitle = strTitle.Replace("---", "-")
strTitle = strTitle.Replace("----", "-")
strTitle = strTitle.Replace("-----", "-")
strTitle = strTitle.Replace("----", "-")
strTitle = strTitle.Replace("---", "-")
strTitle = strTitle.Replace("--", "-")
strTitle = strTitle.Replace("'", "-")
'Run the code again...
'Trim Start and End Spaces.
strTitle = strTitle.Trim()
'Trim "-" Hyphen
strTitle = strTitle.Trim("-"c)
Return strTitle
EndFunction